Found this in an old blog where i wanted to write about software.
So 2 years ago i learned about the Pomodoro technique where you basically focus on working without any distractions for a set time, say 25 mins, then have a break for 5 mins. Sort of a mini sprint. I found the idea interesting and unfortunately got distracted into writing this script for a timer on my desktop. Its a bit messy but it does the job.
Should work well for ubuntu or elementary OS or probably anything running debian based linux as well.
#!/bin/bash # # BASH pomodoro timer: Starts a timer for 25 mins for work, # then 5 mins for rest. This is based on the pomodoro technique. # # hazlan@gmail.com 20140612 # function print_bar { TERMCOLS=$(tput cols) BARWIDTH=$(($TERMCOLS – 12)) BARLEFT=$(($1 * $BARWIDTH / $2)) BARDONE=$(($BARWIDTH – $BARLEFT)) BAR=$(printf ‘#%.0s’ `seq 1 $BARLEFT`)$(printf ‘.%.0s’ `seq 1 $BARDONE`}) TIME=$((($THEN – $NOW)/60)) printf “%8s [%.${BARWIDTH}s] \r” $1 $BAR } function countdown { NOW=$(date +%s) THEN=$(($NOW + $1)) echo Due: $(date -d @$THEN) while [ $THEN -gt $NOW ]; do print_bar $(($THEN – $NOW)) $1 if [ `echo “$(($THEN – $NOW))%30” | bc` -eq 0 ]; then notify-send “Pomodoro Timer” `echo “$(($THEN – $NOW))/60″ | bc`”:”`echo “$(($THEN – $NOW))%60″ | bc`” mins left.” -i clock fi; sleep 1 NOW=$(date +%s) done; print_bar 0 $1 } function countdownrest { NOW=$(date +%s) THEN=$(($NOW + $1)) echo Due: $(date -d @$THEN) while [ $THEN -gt $NOW ]; do print_bar $(($THEN – $NOW)) $1 if [ `echo “$(($THEN – $NOW))%30” | bc` -eq 0 ]; then notify-send “Pomodoro Timer” `echo “$(($THEN – $NOW))/60″ | bc`”:”`echo “$(($THEN – $NOW))%60″ | bc`” mins left.” -i face-laugh fi; sleep 1 NOW=$(date +%s) done; print_bar 0 $1 } countdown 1500 echo -e ‘\n\aTimer finished.’ paplay /home/hazlan/Tools/android-sdk-linux/platforms/android-15/data/res/raw/fallbackring.ogg which notify-send >/dev/null && notify-send “Pomodoro Work Timer [25mins] finished. Go rest 5mins.” -i face-laugh countdownrest 300 echo -e ‘\n\aTimer finished.’ paplay /home/hazlan/Tools/android-sdk-linux/platforms/android-15/data/res/raw/fallbackring.ogg which notify-send >/dev/null && notify-send “Rest Work Timer [5mins] finished. Go back to work! ” -i face-cool
Recent posts