Angelos Orfanakos

DIY Pomodoro with cron

I recently wanted to employ the Pomodoro Technique to remember to take regular breaks from the computer.

Being a fan of DIY for simple things, I decided to implement it with cron, desktop notifications and a subtle chime sound.

Execute crontab -e from a terminal and write:

0,30 * * * * DISPLAY=:0.0 notify-send -t 10000 Pomodoro 'Back to work!'; XDG_RUNTIME_DIR=/run/user/1000 paplay /usr/share/sounds/freedesktop/stereo/complete.oga
25,55 * * * * DISPLAY=:0.0 notify-send -t 10000 -u critical Pomodoro 'Time for a 5-minute break!'; XDG_RUNTIME_DIR=/run/user/1000 paplay /usr/share/sounds/freedesktop/stereo/complete.oga

Things to note:

  • At 0 and 30 minutes past you get a Back to work! notification and sound
  • At 25 and 55 minutes past you get a Time for a 5-minute break! notification and sound
  • Notifications are automatically dismissed after 10 seconds
  • 1000 is your user id. You can get it with echo $UID from a terminal.
  • paplay plays sounds with PulseAudio
  • /usr/share/sounds/freedesktop/stereo/complete.oga is the path to the audio file and is part of the sound-theme-freedesktop package in Debian (may be missing from your system)

If you prefer 50 minutes of work followed by a 10-minute break:

0 * * * * DISPLAY=:0.0 notify-send -t 10000 Pomodoro 'Back to work!'; XDG_RUNTIME_DIR=/run/user/1000 paplay /usr/share/sounds/freedesktop/stereo/complete.oga
50 * * * * DISPLAY=:0.0 notify-send -t 10000 -u critical Pomodoro 'Time for a 10-minute break!'; XDG_RUNTIME_DIR=/run/user/1000 paplay /usr/share/sounds/freedesktop/stereo/complete.oga

Thanks to zorbash for the idea to use desktop notifications.