Category Archives: Pomodoro Timer

Shell Script Pomodoro Timer

If I have difficulty concentrating on a task I find the Pomodoro Technique very useful. When I was a manager or developer on software projects then it was too easy to get distracted by things like email or other discussions. With the Pomodoro Technique I could cleanly partition my work, for example, do three Pomodoros working on a project followed by one for email, one for phone calls etc.

On a Windows PC I found Tomighty to be quite effective but unfortunately there isn’t a Linux version. There are plenty of web based ones available but all the native Linux versions I found seemed to need either Java or libraries that I didn’t have installed. So I did what any self respecting engineer would do and I wrote my own 🙂

I did think of making it purely command line shell based but I find it more useful to have a small window on screen showing the time remaining etc. rather than having to use a terminal window. After some deliberation I implemented the basic control in a shell script and used Zenity to provide the user interaction. To use the script you may need to install Zentity, depending on your distro.

The code is available on GitHub ( https://github.com/john-davies/shellpomo ) and is largely self explanatory but the following may be useful to note:

1. There are a number of default values at the start of the script. The time intervals for the Pomodoros are those defined by the Pomodoro Technique website but feel free to modify as necessary. The whole script is a bit Ubuntu-centric where the notification sound is concerned but it’s a simple matter to change the appropriate line if necessary.

2. The script simply asks the user for the number of Pomodoros then steps through each one displaying the various countdowns as necessary. The user can abort the whole process at any time but there’s currently no way of handling any interruptions to a particular Pomodoro.

3. The Zenity commands are all explained in the manual. The only one that’s slightly convoluted is the display of the progress bar:

progressbarThe key here are the following lines from the “Process Dialog” manual page:

“Zenity reads data from standard input line by line. If a line is prefixed with #, the text is updated with the text on that line. If a line contains only a number, the percentage is updated with that number.”

The countdown is done in the countdown() function and the dialog is updated using the following lines:

printf "# Time remaining: %d:%02d\n" $(( t/60 )) $(( t % 60 ));
echo "$(( ( ( TIME - t ) * 100 ) / TIME ))";
( Note the # in the printf line )

launcherThe GitHub repository contains a “.desktop” file which can be dragged onto the Ubuntu Launcher to create a shortcut complete with a suitable icon. For Ubuntu Mate then right click on the desktop and select “Create Launcher …” then add the various details and a launcher complete with icon will appear on the desktop.

I’ve used this off and on for over a year now and it works fine for me. I’ve never needed the “interruptions” handling but it should be fairly easy to add a feature to log any Pomodoros that have been interrupted and report these at the end.