Advertisement
systems_architect

Productivity Timer Script, v. 0.21

Apr 8th, 2020
441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 6.74 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # fiteme v. 0.21 by Marc Carson
  4. # 5 April 2020
  5. #
  6. # This script allows a user to select a chained timer sequence, for example
  7. # 15 minute Circle tasks, 5 minute planning, 25 minute work.
  8. # Timer concept based on TaskBATL "FiTe Timer" module by Marc Carson
  9. # More info:
  10. # https://www.friendlyskies.net/intj/the-balance-first-approachable-to-do-list
  11. #
  12. # Dependencies: zenity, espeak
  13. # Configuration: You will need to change the Scriptlocation strings below
  14. #  so that the script knows where to find your script.
  15. #
  16. ## To-Do List
  17. ## TODO: Move the local file references into a configuration var up top.
  18. ## TODO: Make the script a tad more efficient. :]=
  19. ## TODO: Make the script location automatic
  20. #
  21. # Marc Carson
  22. # https://www.friendlyskies.net
  23. # https://www.marccarsoncoaching.com
  24.  
  25. function zenityNoWarn() {
  26.     # Replace default zenity call with this handy Gtk error suppressor.
  27.     # Without this you'll get Gtk Warnings in the terminal output.
  28.     # Added 2020-04-05
  29.     zenity "$@" 2> >(grep -v 'GtkDialog' >&2)
  30. }
  31.  
  32. fitenormal () {
  33.     # 15, 5, 25 minute timer function
  34.     if zenityNoWarn --question --text="Start 15 minute circle timer?"; then
  35.         zenityNoWarn --notification\
  36.             --window-icon="info" \
  37.             --text="Have fun for 15 minutes!"
  38.         time=$(date +%T)
  39.         echo "**Started 15m block with circle," $time
  40.         sleep 13m
  41.         espeak "Two minutes of circle timer left."
  42.         zenityNoWarn --notification\
  43.             --window-icon="info" \
  44.             --text="2 minutes left in circle timer."
  45.         sleep 2m
  46.         espeak "Circle timer complete."
  47.     else
  48.         exit 1
  49.     fi
  50.     if zenityNoWarn --question --text="Start 5 minute planning?"; then
  51.         zenityNoWarn --notification\
  52.             --window-icon="info" \
  53.             --text="Planning or howling for 5 minutes begins now"
  54.         time=$(date +%T)
  55.         echo "Started 5m planning block," $time
  56.         sleep 3m
  57.         zenityNoWarn --notification\
  58.             --window-icon="info" \
  59.             --text="2 minutes left in planning timer."
  60.         espeak "Two minutes of planning left."
  61.         sleep 2m
  62.         espeak "Planning timer complete."
  63.     else
  64.         exit 1
  65.     fi
  66.  
  67.     if zenityNoWarn --question --text="Start 25 minute work tasks?"; then
  68.         zenityNoWarn --notification\
  69.             --window-icon="info" \
  70.             --text="Work for 25 minutes begins now"
  71.         time=$(date +%T)
  72.         echo "Started 25m work block," $time
  73.         sleep 23m
  74.         espeak "Two minutes of work left."
  75.         zenityNoWarn --notification\
  76.             --window-icon="info" \
  77.             --text="2 minutes left in work timer."
  78.         sleep 2m
  79.         espeak "Work timer complete."
  80.     else
  81.         exit 1
  82.     fi
  83.     if zenityNoWarn --question --text="Cycle complete. Start new timer?"; then
  84.         ScriptLocation=$(/home/marc/Dropbox/bin/fiteme)
  85.         exec "$ScriptLocation"
  86.     else
  87.         exit 1
  88.     fi
  89. }
  90.  
  91. fiteheavy () {
  92.     # 45-10-25 minute timer function
  93.     if zenityNoWarn --question --text="Start 45 minute circle timer..."; then
  94.         zenityNoWarn --notification\
  95.             --window-icon="info" \
  96.             --text="Circle activities for 45 minutes begins now"
  97.         time=$(date +%T)
  98.         echo "**Started 45m block with circle," $time
  99.         sleep 40m
  100.         espeak "Five minutes of circle left."
  101.         zenityNoWarn --notification\
  102.             --window-icon="info" \
  103.             --text="2 minutes left in circle timer."
  104.         sleep 5m
  105.         espeak "All done with circle. The circle timer has finished."
  106.     else
  107.         exit 1
  108.     fi
  109.     if zenityNoWarn --question --text="Start 10 minute planning?"; then
  110.         zenityNoWarn --notification\
  111.             --window-icon="info" \
  112.             --text="Planning or howling for 10 minutes begins now"
  113.         time=$(date +%T)
  114.         echo "Started 10m planning block," $time
  115.         sleep 8m
  116.         espeak "Two minutes of planning left."
  117.         zenityNoWarn --notification\
  118.             --window-icon="info" \
  119.             --text="2 minutes left in planning timer."
  120.         sleep 2m
  121.         espeak "Planning cycle complete."
  122.     else
  123.         exit 1
  124.     fi
  125.  
  126.     if zenityNoWarn --question --text="Start 25 minute work tasks?"; then
  127.         zenityNoWarn --notification\
  128.             --window-icon="info" \
  129.             --text="Work for 25 minutes begins now"
  130.         time=$(date +%T)
  131.         echo "Started 25m work block," $time
  132.         sleep 23m
  133.         espeak "Two minutes of work left."
  134.         zenityNoWarn --notification\
  135.             --window-icon="info" \
  136.             --text="2 minutes left in work timer."
  137.         sleep 2m
  138.         espeak "The work cycle is complete."
  139.     else
  140.         exit 1
  141.     fi
  142.     if zenityNoWarn --question --text="Cycle complete. Start new timer?"; then
  143.         ScriptLocation=$(/home/marc/Dropbox/bin/fiteme)
  144.         exec "$ScriptLocation"
  145.     else
  146.         exit 1
  147.     fi
  148. }
  149.  
  150. fitetester () {
  151.     # Test function only; run through a timer cycle quickly.
  152.     if zenityNoWarn --question --text="Start test timer?"; then
  153.         zenityNoWarn --notification\
  154.             --window-icon="info" \
  155.             --text="Have fun for seconds!"
  156.         time=$(date +%T)
  157.         echo "***Started 3s test block," $time
  158.         sleep 3s
  159.     else
  160.         exit 1
  161.     fi
  162.     if zenityNoWarn --question --text="Start planning?"; then
  163.         zenityNoWarn --notification\
  164.             --window-icon="info" \
  165.             --text="Planning or howling for seconds begins now"
  166.         time=$(date +%T)
  167.         echo "***Started 3s test block," $time
  168.         sleep 3s
  169.     else
  170.         exit 1
  171.     fi
  172.  
  173.     if zenityNoWarn --question --text="Start work tasks?"; then
  174.         zenityNoWarn --notification\
  175.             --window-icon="info" \
  176.             --text="Work for seconds begins now"
  177.         time=$(date +%T)
  178.         echo "***Started 3s test block," $time
  179.         sleep 3s
  180.     else
  181.         exit 1
  182.     fi
  183.     if zenityNoWarn --question --text="Cycle complete. Start new timer?"; then
  184.         ScriptLocation=$(/home/marc/Dropbox/bin/fiteme)
  185.         exec "$ScriptLocation"
  186.     else
  187.         exit 1
  188.     fi
  189. }
  190.  
  191. # Start: Present the user with a list of timers to choose.
  192.  
  193. identifier=$(zenityNoWarn --list \
  194.  --title="Choose your timer" \
  195.  --column="Name" --column="Configuration" \
  196.   Normal 15-5-25 \
  197.   FiHeavy 45-10-25 \
  198.   FiteTester 3s-Each)
  199.  
  200. norm="Normal"
  201.  
  202. fiheavy="FiHeavy"
  203.  
  204. tester="FiteTester"
  205.  
  206. if [ "$identifier" = "$norm" ]; then
  207.     # They chose the Normal timer...
  208.     fitenormal
  209. fi
  210.  
  211. if [ "$identifier" = "$fiheavy" ]; then
  212.     # They chose the FiHeavy timer...
  213.     fiteheavy
  214. fi
  215.  
  216. if [ "$identifier" = "$tester" ]; then
  217.     # They chose the FiHeavy timer...
  218.     fitetester
  219. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement