Skip to content

Instantly share code, notes, and snippets.

@nibrahim
Created July 7, 2010 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nibrahim/466899 to your computer and use it in GitHub Desktop.
Save nibrahim/466899 to your computer and use it in GitHub Desktop.
Pomodoro timer as similar to the online focus booster as a shell script
function alarm() {
# First argument is the number of minutes spent on work (one pomodoro)
# Second argument is the rest time.
# I usually invoke this as alarm 30 5 (work for 30 minutes, rest for 5)
work_time=$(echo "$1*60" | bc)
rest_time=$(echo "$2*60" | bc)
( mpg123 --loop -1 ~/scratch/clock-ticking-4.mp3 > /dev/null 2>&1 &
mpg123pid=$!
(sleep ${work_time} &&
kill $mpg123pid &&
mpg123 -d 5 ~/scratch/alarm-clock-1.mp3 > /dev/null 2>&1 &&
mpg123 --loop -1 ~/scratch/clock-ticking-4.mp3 > /dev/null 2>&1 &
mpg123pid=$!
(sleep ${rest_time} &&
kill $mpg123pid &&
mpg123 -d 5 ~/scratch/alarm-clock-1.mp3 > /dev/null 2>&1
)&
)&
)&
disown
}
# Sound effect files obtained from http://www.soundjay.com/clock-sounds-1.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment