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!

Invoking root directorie’s makefile from subdirectory in EMACS

To compile, M-x compile is used in emacs. The value displayed in the mini-buffer for this command is stored in the compile-command variable. When you execute, make -k, emacs executes the command in the directory on which the currently opened file belongs. This won’t help as you may not have makefile in the current directory.

Most of the projects will have only one makefile which will be available in the root directory. To invoke this makefile from a subdirectory, you can use -f switch and specify the makefile path. Something like:

make -f project_root_directory/Makefile

Still, emacs executes this command from the current directory. This method has got potential problems like relative paths used inside the makefile won’t work. A reliable method would be to ask emacs to change the current directory to project’s root, execute the makefile and come back to the current directory. Fortunately, emacs supports cd command which can be used to change the directory and cd – to come back to last directory. After issuing the compile command (M-x compile), you can type

(cd /project_root_directory && make && cd -)

Using this method, emacs executes the makefile from the root directory. You can add the following to .emacs file if you need this trick always.

(setq compile-command "(cd /project_root_directory && make && cd -)")

Happy programming!

Getting smart-completion for wxWidgets using CEDET

This post shows how CEDET can be configured to show code-completion for classes in wxWidgets library. Since wxWidgets uses preprocessor macros heavily, configuring smart-completion is bit tricky. I haven’t got successful completion on my first attempt and got everything worked nicely after having few discussions on the CEDET mailing list. Thanks to all who helped.

This post assumes that you have a CVS version of CEDET installed and configured correctly. Continue reading