Posted By

ksaver on 08/30/10


Tagged

Bash timer pomodoro


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

ksaver


A simple timer to apply The Pomodoro Technique


 / Published in: Bash
 

URL: http://identi.ca/ksaver

  1. #! /usr/bin/env bash
  2. # File: tomatoe.sh
  3. # What the..?: A simple timer to apply The Pomodoro Technique.
  4. # Who the..?: ksaver (at identi.ca).
  5. # Why? : In the Hope of this little script can be useful...
  6. # When?: July 2010.
  7. # Requieres: bash, play, zenity (nix like OS, of course).
  8. # More Info: http://www.pomodorotechnique.com
  9. # License: Public Domain.
  10. # Not any warranty at all.
  11. #---------------------------------------------------------------
  12.  
  13. scriptname=$(basename $0 .sh)
  14. scriptvers='0.6'
  15.  
  16. ## --- Set preferences ---
  17. minute=60 # Secs in one min. 60 (habitually).
  18. m_resting=5 # Resting time. Default 05 minutes.
  19. m_working=25 # Working time. Default 25 minutes.
  20. s_resting=$(($m_resting*$minute)) # seconds to resting.
  21. s_working=$(($m_working*$minute)) # seconds to working.
  22. audio_warning="/home/$USER/Audio/attention.wav" # some cute audio warning.
  23. ## -----------------------
  24.  
  25. function starting_dialog()
  26. {
  27. zen_dialog --title "$scriptname - $scriptvers" --question \
  28. --text="Starting Tomatoe Timer:\
  29. \n$m_working Mins Working/$m_resting Mins Resting."
  30. return $?
  31. }
  32.  
  33. function tomatoe_timer()
  34. {
  35. TASK=$1
  36. LIMIT=$2
  37. COUNT=0
  38. while [ $COUNT -lt $LIMIT ]
  39. do
  40. echo $(($COUNT*100/$LIMIT)) # % percentage %
  41. let COUNT=$COUNT+1
  42. sleep 1
  43. done | zen_dialog --title="Cycles: $count_cycle" --progress --auto-close \
  44. --text="Time to $TASK ($(($LIMIT/$minute)) Mins)...\t"
  45. return $?
  46. }
  47.  
  48. function zen_alert()
  49. {
  50. play "$audio_warning" & # Decomment if you want a sound warning.
  51. zen_dialog --title="Cycles: $count_cycle" --question \
  52. --text="Time to $1 has Finished!\nShall I Continue?"
  53. return $?
  54. }
  55.  
  56. function zen_dialog()
  57. {
  58. /usr/bin/env zenity "$@"
  59. }
  60.  
  61. function __main__()
  62. {
  63. count_cycle=1
  64. starting_dialog || exit
  65. while true
  66. do
  67. tomatoe_timer "Working" $s_working
  68. zen_alert "Working" || exit
  69. tomatoe_timer "Slacking" $s_resting
  70. zen_alert "Slacking" || exit
  71. let count_cycle=$count_cycle+1
  72. done
  73. }
  74.  
  75. ## Run script...
  76. __main__

Report this snippet  

You need to login to post a comment.