What is this?
I use countdown timers several times each day. Need to brew some tea? Setup a timer. Need to catch the bus in 20 minutes? Setup a timer. Waiting for the laundry to finish? Setup a timer. You get the idea. Because I use this functionality so much it has to be convenient. Getting out my phone, launching some timer app and telling it to start the countdown is not convenient. Much in the same way, launching applications on OS X is also not convenient if you do it by navigating to the Applications folder and double-clicking an application icon. Luckily there is a nice solution for both problems. It is called Alfred.
Alfred is a Spotlight-based application launcher that uses a text-based interface. But this description does not really do it justice. Alfred is much more than that. Alfred not only launches applications it also allows you to navigate the filesystem and to access various contextual actions, for example deleting a file or emailing it to someone. Alfred is very flexible and can be extended with custom commands called extensions. Extensions can either provide new contextual actions or additional commands.
For my daily countdown timer needs I implemented an Alfred extension. The extension allows me to start countdown timers quickly and hassle-free. The extension uses Mountain Lion’s user notifications and sound to tell you when the time is up.
All code for the extension is available on GitHub. It is implemented in Python, so please take a look if you are interested in extending Alfred with Python or if you want to find out how to work with Mountain Lion’s user notifications from Python.
What are the benefits?
- Helps you make great tea.
- Solves your Pomodoro needs.
- Uses Mountain Lion’s User Notifications to tell you when time’s up.
- Plays a non-intrusive alarm sound.
- Allows you to run multiple timers at the same time.
- Allows you to add an optional label to the timer, e.g. “Laundry is done!”.
- Shows you how to write Alfred extensions in Python.
How to install it?
Depending on whether you’re running Alfred 1 or Alfred 2 you need different versions of the extension. Please also note that this extension / workflow requires OS X Mountain Lion (10.8) or greater to work. Additionally, you need the Alfred PowerPack.
For Alfred 2 download and double-click Timer.alfredworkflow to install the workflow.
For Alfred 1 download and double-click Timer.alfredextension to install the extension.
How to use it?
- The general syntax is
timer [minutes] [optional:title]
timer 5sets a countdown timer that goes off after 5 minutes.
timer 0.5sets a timer that goes off after 30 seconds.
timer 40 Laundry is done!adds an optional title to the timer.
timerdisplays usage information.
Update: Even more notification fixes
Thanks to some more hacking (GitHub issues #1 and #6) the problem where notifications would fail to display was resolved. Additionally, all notification windows now correctly display Alfred’s application icon. These fixes are included in the latest version of the workflow / extension.
Update: Support for Alfred v2
I’ve repackaged the extension into an Alfred v2 workflow. This means it’s now also possible to use the timer from Alfred v2. Functionality and usage are the same in both versions.
Update: Timer labels
Alexander Lehmann suggested that the timer could be improved by adding an additonal label argument. The label is displayed when the timer starts and when it fires. This helps running multiple timers at once without getting confused. Labels are added by simply by typing the label after the time interval. For example,
timer 3:30 tea is done will get you the following result:
Update: Notification fixes
Jay Zawrotny has reported an issue with the extension where notifications would not fire correctly. I believe that there is a codesigning problem on systems where Mountain Lion’s vanilla Python install is replaced. If you have issues with getting notifications to show up please try Jay’s suggested fix from this pull request on GitHub. Thanks Jay!