Starting Hamster with Super+H

7/18/18 last edited: 7/18/18

A while ago I was looking for a time tracker or calendar solution, which was hopefully also open source. Hamster is a lightweight tool which does its job very well. It is quick and easy to begin tracking activities and the data can be exported in an html file for external processing. While the tool was very nice, at first it was slightly cumbersome to begin tracking activities and I had read on various forums that one could begin tracking activities by entering super+H. Unfortunately this command was not available in the version bundled with Ubuntu 16.04. In order to add this functionality I opened system settings->keyboard->shortcuts->custom shortcuts, then I bound super+H to the script below.

# @File Switch between current window and Hamster Time Tracker

if test $(wmctrl -l | grep "Time Tracker" 2>&1 | wc -l) -eq 1; then
	wmctrl -a "Time Tracker"
	else python2 /usr/bin/hamster-time-tracker &

The script works by first finding if time tracker app is already open, and if so changing the window to the time tracker app. Otherwise Hamster is started by python, if your hamster install is located in a different location then you need change /usr/bin/hamster-time-tracker to wherever you have installed hamster. It is a kludge but I found that this script worked more reliably than other super+H scripts that I have found on the Internet.