1. Yusuke MURAOKA
  2. scratch

Source

scratch / scripts / pomodoro

#!/usr/bin/env bash

start_serif="The pomodoro \"$1\" is started."
stop_serif="The pomodoro \"$1\" is stopped."
done_serif="The pomodoro \"$1\" has been done."

function growl_say {
    growlnotify $1 "$2"; say "$2"
}

function pomodoro_stop {
    growl_say "-s -m" "$stop_serif"
    echo "\n$stop_serif"
    exit 1
}

trap "pomodoro_stop" INT

function pomodoro_done {
    growl_say "-s -m" "$done_serif"
    echo "\n$done_serif"
}

cnt=$((25 * 60))  # 25 minutes

growl_say -m "$start_serif"

echo "The pomodoro: \"$1\""
while [ $cnt -ge 0 ]
do
    minutes=$((cnt / 60))
    seconds=$((cnt % 60))
    printf "\rcount down: %02d:%02d" $minutes $seconds
    sleep 1
    cnt=$(($cnt - 1))
done

pomodoro_done