Simple egg timer on Linux for Pomodoro technique

Recently I have started evaluating the Pomodoro Technique which I found quite interesting. I am still evaluating the technique and not yet concluded on whether I should continue using it.

To implement pomodoro technique, you need a kitchen timer or egg timer. Since I use pomodoro for my programming work, I obviously don’t want to use a physical timer. I couldn’t find a decent timer for linux especially one that works well with Xfce. In this blog post, I will explain building a kitchen timer with basic linux programming techniques. This also gives an idea about how simple linux tools can be combined to do useful stuff.

Things that are used

  1. Shell scripting
  2. Notification mechanisms on popular desktops like Gnome and Xfce. (I use Xfce in this example)

The shell script is actually a modified version of the one published here (http://mostlylinux.wordpress.com/commandline/eggtimer/).

#!/bin/bash
counter=0
limit=$1
summary=$2
startmessage=$3
endmessage=$4
notify-send -u critical -i appointment -t 600 "$summary" "$startmessage"
echo
while [ $counter != $limit ]; do
   echo "$counter minutes so far...";
   sleep 60
   let "counter = $counter + 1"
done
if [ $counter = $limit ]; then
   echo
   notify-send -u critical -i appointment "$summary" "$endmessage"
   echo -e '\a' >&2
   exit 0
fi

All it does is wait until the limit reaches. It uses the sleep(1) command to sleep for a minute. notify-send is used for sending notifications to the desktop environment.

This script can be invoked using,

./p-timer.sh

If you use bash, you can add an alias for convenience.

alias begin-pomodoro='sh ~/utils/p-timer.sh 25 "Pomodoro" "Pomodoro started, you have 25 minutes left" "Pomodoro ended. Please stop the work and take short break"'

Pomodoro started notification

Pomodoro ended notification

This post is written on one pomodoro!

Happy programming!

Advertisements

3 thoughts on “Simple egg timer on Linux for Pomodoro technique

  1. thanks, just what i was looking for… note when using gnome-shell:

    add –hint=int:transient:1 to notify-send (so notifications won’t linger in the notification area).
    remove -u critical (notification will disappear by itself after a while, personal preference i guess)

    also a small paste error in above code:

    >&2 should be >&2

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s