Advertisement
Guest User

Bash Pomodoro Timer

a guest
Dec 12th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.33 KB | None | 0 0
  1. ::::::::::::::
  2. pomodoro
  3. ::::::::::::::
  4. #!/bin/bash
  5. POMS=1
  6.  
  7. while :
  8. do
  9.     if [ $((POMS%4)) == 0 ]; then
  10.         timer -m="Take a long break" 25
  11.         timer -m="Get back to work!" 15
  12.     else
  13.         timer -m="Take a short break" 25
  14.         timer -m="Get back to work!" 5
  15.     fi
  16.     echo "Pomodori completed: $POMS"
  17.     notify-send "Pomodori completed: $POMS"
  18.     POMS=$(( POMS+1 ))
  19. done
  20.  
  21. ::::::::::::::
  22. timer
  23. ::::::::::::::
  24. #!/bin/bash
  25. # Usage: timer [-m="message"] [-s] [ minutes | hours minutes seconds]
  26. # OPTIONS
  27. # -m=*  Attach a message to display
  28.  
  29. # default option values
  30. SOUND=1
  31.  
  32. # check for options
  33. OPTIONS=1
  34. while [[ $OPTIONS > 0 ]]; do
  35. case $1 in
  36. -*)
  37.     #echo "${1#-*}"
  38.     case $1 in
  39.     -m=*|--message=*)
  40.         MESSAGE="${1#*=}";;
  41.     -s|--silent)
  42.         SOUND=0;;  
  43.     esac
  44.     shift;;
  45. *)
  46.     OPTIONS=0;;
  47. esac
  48. done
  49.  
  50. # assign inputs to variables
  51. case $# in
  52. 1)
  53.     h=0; m=$1; s=0;;
  54. 2)
  55.     h=0; m=$1; s=$2;;
  56. 3)
  57.     h=$1; m=$2; s=$3;;
  58. esac
  59.  
  60. echo "Timer started at $(date)"
  61. sleep $(( $h * 3600 + $m * 60 + $s ))
  62. echo "Timer elapsed at $(date)"
  63. echo $MESSAGE
  64. #tput bel
  65. notify-send 'Timer' "$MESSAGE" -i /usr/share/icons/Papirus/64x64@2x/categories/preferences-desktop-notification-bell.svg
  66. if [ $SOUND == 1 ]; then
  67.     paplay /home/owb/sounds/wav/Metal_Gong-Dianakc-109711828.wav &
  68. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement