Advertisement
systems_architect

Productivity Timer Script, v. 0.3

Apr 13th, 2020
1,083
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 10.72 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # fiteme v. 0.3 by Marc Carson
  4. # 13 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. #
  14. ## To-Do List
  15. ## TODO: Move the local file references into a configuration var up top.
  16. ## TODO: Make the script a tad more efficient. :]=
  17. ##
  18. # Marc Carson
  19. # https://www.friendlyskies.net
  20. # https://www.marccarsoncoaching.com
  21.  
  22. function zenityNoWarn() {
  23.     # Replace default zenity call with this handy Gtk error suppressor.
  24.     # Without this you'll get Gtk Warnings in the terminal output.
  25.     # Added 2020-04-05
  26.     zenity "$@" 2> >(grep -v 'GtkDialog' >&2)
  27. }
  28.  
  29. fitenormal () {
  30.     # 15, 5, 25 minute timer function
  31.     if zenityNoWarn --question --text="Start 15 minute circle timer?"; then
  32.         zenityNoWarn --notification\
  33.             --window-icon="info" \
  34.             --text="Have fun for 15 minutes!"
  35.         time=$(date +%T)
  36.         echo "**Started 15m block with circle," $time
  37.         sleep 13m
  38.         espeak "Two minutes of circle timer left."
  39.         zenityNoWarn --notification\
  40.             --window-icon="info" \
  41.             --text="2 minutes left in circle timer."
  42.         sleep 2m
  43.         espeak "Circle timer complete."
  44.     else
  45.         exit 1
  46.     fi
  47.     if zenityNoWarn --question --text="Start 5 minute planning?"; then
  48.         zenityNoWarn --notification\
  49.             --window-icon="info" \
  50.             --text="Planning or howling for 5 minutes begins now"
  51.         time=$(date +%T)
  52.         echo "Started 5m planning block," $time
  53.         sleep 3m
  54.         zenityNoWarn --notification\
  55.             --window-icon="info" \
  56.             --text="2 minutes left in planning timer."
  57.         espeak "Two minutes of planning left."
  58.         sleep 2m
  59.         espeak "Planning timer complete."
  60.     else
  61.         exit 1
  62.     fi
  63.  
  64.     if zenityNoWarn --question --text="Start 25 minute work tasks?"; then
  65.         zenityNoWarn --notification\
  66.             --window-icon="info" \
  67.             --text="Work for 25 minutes begins now"
  68.         time=$(date +%T)
  69.         echo "Started 25m work block," $time
  70.         sleep 23m
  71.         espeak "Two minutes of work left."
  72.         zenityNoWarn --notification\
  73.             --window-icon="info" \
  74.             --text="2 minutes left in work timer."
  75.         sleep 2m
  76.         espeak "Work timer complete."
  77.     else
  78.         exit 1
  79.     fi
  80.     if zenityNoWarn --question --text="Cycle complete. Start new timer?"; then
  81.         ScriptLocation=$(/home/marc/Dropbox/bin/fiteme)
  82.         exec "$ScriptLocation"
  83.     else
  84.         exit 1
  85.     fi
  86. }
  87.  
  88. fiteheavy () {
  89.     # 45-10-25 minute timer function
  90.     if zenityNoWarn --question --text="Start 45 minute circle timer..."; then
  91.         zenityNoWarn --notification\
  92.             --window-icon="info" \
  93.             --text="Circle activities for 45 minutes begins now"
  94.         time=$(date +%T)
  95.         echo "**Started 45m block with circle," $time
  96.         sleep 40m
  97.         espeak "Five minutes of circle left."
  98.         zenityNoWarn --notification\
  99.             --window-icon="info" \
  100.             --text="2 minutes left in circle timer."
  101.         sleep 5m
  102.         espeak "All done with circle. The circle timer has finished."
  103.     else
  104.         exit 1
  105.     fi
  106.     if zenityNoWarn --question --text="Start 10 minute planning?"; then
  107.         zenityNoWarn --notification\
  108.             --window-icon="info" \
  109.             --text="Planning or howling for 10 minutes begins now"
  110.         time=$(date +%T)
  111.         echo "Started 10m planning block," $time
  112.         sleep 8m
  113.         espeak "Two minutes of planning left."
  114.         zenityNoWarn --notification\
  115.             --window-icon="info" \
  116.             --text="2 minutes left in planning timer."
  117.         sleep 2m
  118.         espeak "Planning cycle complete."
  119.     else
  120.         exit 1
  121.     fi
  122.  
  123.     if zenityNoWarn --question --text="Start 25 minute work tasks?"; then
  124.         zenityNoWarn --notification\
  125.             --window-icon="info" \
  126.             --text="Work for 25 minutes begins now"
  127.         time=$(date +%T)
  128.         echo "Started 25m work block," $time
  129.         sleep 23m
  130.         espeak "Two minutes of work left."
  131.         zenityNoWarn --notification\
  132.             --window-icon="info" \
  133.             --text="2 minutes left in work timer."
  134.         sleep 2m
  135.         espeak "The work cycle is complete."
  136.     else
  137.         exit 1
  138.     fi
  139.     if zenityNoWarn --question --text="Cycle complete. Start new timer?"; then
  140.         ScriptLocation=$(/home/marc/Dropbox/bin/fiteme)
  141.         exec "$ScriptLocation"
  142.     else
  143.         exit 1
  144.     fi
  145. }
  146.  
  147. tefinormal () {
  148.     # 25, 5, 15 minute timer function
  149.     if zenityNoWarn --question --text="Start 25 minute task timer?"; then
  150.         zenityNoWarn --notification\
  151.             --window-icon="info" \
  152.             --text="Get on task for 25 minutes!"
  153.         time=$(date +%T)
  154.         echo "**Started 25m task block," $time
  155.         sleep 23m
  156.         espeak "Two minutes of circle timer left."
  157.         zenityNoWarn --notification\
  158.             --window-icon="info" \
  159.             --text="2 minutes left in task timer."
  160.         sleep 2m
  161.         espeak "Task timer complete."
  162.     else
  163.         exit 1
  164.     fi
  165.     if zenityNoWarn --question --text="Start 5 minute debriefing?"; then
  166.         zenityNoWarn --notification\
  167.             --window-icon="info" \
  168.             --text="Debriefing for 5 minutes begins now"
  169.         time=$(date +%T)
  170.         echo "Started 5m debriefing block," $time
  171.         sleep 3m
  172.         zenityNoWarn --notification\
  173.             --window-icon="info" \
  174.             --text="2 minutes left in debriefing timer."
  175.         espeak "Two minutes of debriefing left."
  176.         sleep 2m
  177.         espeak "Debriefing timer complete."
  178.     else
  179.         exit 1
  180.     fi
  181.  
  182.     if zenityNoWarn --question --text="Start 15 minute circle timer?"; then
  183.         zenityNoWarn --notification\
  184.             --window-icon="info" \
  185.             --text="Circle activities for 15 minutes begins now"
  186.         time=$(date +%T)
  187.         echo "Started 15m circle block," $time
  188.         sleep 13m
  189.         espeak "Two minutes of work left."
  190.         zenityNoWarn --notification\
  191.             --window-icon="info" \
  192.             --text="2 minutes left in work timer."
  193.         sleep 2m
  194.         espeak "Work timer complete."
  195.     else
  196.         exit 1
  197.     fi
  198.     if zenityNoWarn --question --text="Cycle complete. Start new timer?"; then
  199.         ScriptLocation=$(/home/marc/Dropbox/bin/fiteme)
  200.         exec "$ScriptLocation"
  201.     else
  202.         exit 1
  203.     fi
  204. }
  205.  
  206. tefiheavy () {
  207.     # 45, 10, 25 minute timer function
  208.     if zenityNoWarn --question --text="Start 45 minute task timer?"; then
  209.         zenityNoWarn --notification\
  210.             --window-icon="info" \
  211.             --text="Get on task for 45 minutes!"
  212.         time=$(date +%T)
  213.         echo "**Started 45m task block," $time
  214.         sleep 43m
  215.         espeak "Two minutes of task timer left."
  216.         zenityNoWarn --notification\
  217.             --window-icon="info" \
  218.             --text="2 minutes left in task timer."
  219.         sleep 2m
  220.         espeak "Task timer complete."
  221.     else
  222.         exit 1
  223.     fi
  224.     if zenityNoWarn --question --text="Start 10 minute debrief?"; then
  225.         zenityNoWarn --notification\
  226.             --window-icon="info" \
  227.             --text="Debriefing for 10 minutes begins now"
  228.         time=$(date +%T)
  229.         echo "Started 10m debriefing block," $time
  230.         sleep 7m
  231.         zenityNoWarn --notification\
  232.             --window-icon="info" \
  233.             --text="2 minutes left in debriefing timer."
  234.         espeak "Two minutes of debriefing left."
  235.         sleep 3m
  236.         espeak "Debriefing timer complete."
  237.     else
  238.         exit 1
  239.     fi
  240.  
  241.     if zenityNoWarn --question --text="Start 25 minute circle timer?"; then
  242.         zenityNoWarn --notification\
  243.             --window-icon="info" \
  244.             --text="Circle timer for 25 minutes begins now"
  245.         time=$(date +%T)
  246.         echo "Started 25m circle block," $time
  247.         sleep 23m
  248.         espeak "Two minutes of circle timer left."
  249.         zenityNoWarn --notification\
  250.             --window-icon="info" \
  251.             --text="2 minutes left in circle timer."
  252.         sleep 2m
  253.         espeak "Circle timer complete."
  254.     else
  255.         exit 1
  256.     fi
  257.     if zenityNoWarn --question --text="Cycle complete. Start new timer?"; then
  258.         ScriptLocation=$(/home/marc/Dropbox/bin/fiteme)
  259.         exec "$ScriptLocation"
  260.     else
  261.         exit 1
  262.     fi
  263. }
  264.  
  265. fitetester () {
  266.     # Test function only; run through a timer cycle quickly.
  267.     if zenityNoWarn --question --text="Start test timer?"; then
  268.         zenityNoWarn --notification\
  269.             --window-icon="info" \
  270.             --text="Have fun for seconds!"
  271.         time=$(date +%T)
  272.         echo "***Started 3s test block," $time
  273.         sleep 3s
  274.     else
  275.         exit 1
  276.     fi
  277.     if zenityNoWarn --question --text="Start planning?"; then
  278.         zenityNoWarn --notification\
  279.             --window-icon="info" \
  280.             --text="Planning or howling for seconds begins now"
  281.         time=$(date +%T)
  282.         echo "***Started 3s test block," $time
  283.         sleep 3s
  284.     else
  285.         exit 1
  286.     fi
  287.  
  288.     if zenityNoWarn --question --text="Start work tasks?"; then
  289.         zenityNoWarn --notification\
  290.             --window-icon="info" \
  291.             --text="Work for seconds begins now"
  292.         time=$(date +%T)
  293.         echo "***Started 3s test block," $time
  294.         sleep 3s
  295.     else
  296.         exit 1
  297.     fi
  298.     if zenityNoWarn --question --text="Cycle complete. Start new timer?"; then
  299.         ScriptLocation=$(/home/marc/Dropbox/bin/fiteme)
  300.         exec "$ScriptLocation"
  301.     else
  302.         exit 1
  303.     fi
  304. }
  305.  
  306. # Start: Present the user with a list of timers to choose.
  307.  
  308. identifier=$(zenityNoWarn --list \
  309.  --title="Choose your timer" \
  310.  --column="Name" --column="Configuration" \
  311.   FiNormal 15-5-25 \
  312.   FiHeavy 45-10-25 \
  313.   TeNormal 25-5-15 \
  314.   TeHeavy 45-10-25 \
  315.   FiteTester 3s-Each)
  316.  
  317. norm="Normal"
  318.  
  319. fiheavy="FiHeavy"
  320.  
  321. tenorm="TeNormal"
  322.  
  323. teheavy="TeHeavy"
  324.  
  325. tester="FiteTester"
  326.  
  327. if [ "$identifier" = "$norm" ]; then
  328.     # They chose the Normal timer...
  329.     fitenormal
  330. fi
  331.  
  332. if [ "$identifier" = "$fiheavy" ]; then
  333.     # They chose the FiHeavy timer...
  334.     fiteheavy
  335. fi
  336.  
  337. if [ "$identifier" = "$tenorm" ]; then
  338.     # They chose the FiHeavy timer...
  339.     tefinormal
  340. fi
  341.  
  342. if [ "$identifier" = "$teheavy" ]; then
  343.     # They chose the FiHeavy timer...
  344.     tefiheavy
  345. fi
  346.  
  347. if [ "$identifier" = "$tester" ]; then
  348.     # They chose the FiHeavy timer...
  349.     fitetester
  350. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement