From 37cdf1536d41e53fdbbcd75ba1f1d3a5657e0aa5 Mon Sep 17 00:00:00 2001 From: salad Date: Thu, 6 Nov 2025 19:22:57 +0000 Subject: [PATCH 1/2] Update to modern POSIX specifications; Remove legacy bash notation --- scripts/pomodoro.sh | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/scripts/pomodoro.sh b/scripts/pomodoro.sh index 0838dd3..f070c4a 100755 --- a/scripts/pomodoro.sh +++ b/scripts/pomodoro.sh @@ -5,40 +5,40 @@ # The second argument is the break length. # Made by Kiailandi (https://github.com/kiailandi) -wseconds=${1:-25}*60; -pseconds=${2:-wseconds/300}*60; +wseconds="${1:-25}*60"; +pseconds="${2:-wseconds/300}*60"; # Check os and behave accordingly if [ "$(uname)" == "Darwin" ]; then while true; do - date1=$((`date +%s` + $wseconds)); - while [ "$date1" -ge `date +%s` ]; do - echo -ne "$(date -u -j -f %s $(($date1 - `date +%s`)) +%H:%M:%S)\r"; + date1=$(($(date +%s) + wseconds)) + while [ "$date1" -ge $(('date +%s')) ]; do + echo -ne "$(date -u -j -f %s $((date1 - $(date +%s))) +%H:%M:%S)\r" done osascript -e 'display notification "Time to walk and rest!" with title "Break"'; read -n1 -rsp $'Press any key to continue or Ctrl+C to exit...\n'; - date2=$((`date +%s` + $pseconds)); - while [ "$date2" -gt `date +%s` ]; do - echo -ne "$(date -u -j -f %s $(($date2 - `date +%s`)) +%H:%M:%S)\r"; + date2=$(($(date +%s) + pseconds)) + while [ "$date2" -ge "$(date +%s)" ]; do + echo -ne "$(date -u -j -f %s $((date2 - $(date +%s))) +%H:%M:%S)\r" done osascript -e 'display notification "Time to get back to work" with title "Work"'; read -n1 -rsp $'Press any key to continue or Ctrl+C to exit...\n'; done -elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then +elif [ "$(printf "%s" "$(uname -s)" | cut -c 1-5)" == "Linux" ] ; then while true; do - date1=$((`date +%s` + $wseconds)); - while [ "$date1" -ge `date +%s` ]; do - echo -ne "$(date -u --date @$(($date1 - `date +%s` )) +%H:%M:%S)\r"; + date1=$(($(date +%s) + wseconds)); + while [ "$date1" -ge "$(date +%s)" ]; do + echo -ne "$(date -u --date @$((date1 - $(date +%s))) +%H:%M:%S)\r" done notify-send "Break" "Time to walk and rest"; read -n1 -rsp $'Press any key to continue or Ctrl+C to exit...\n'; - date2=$((`date +%s` + $pseconds)); - while [ "$date2" -ge `date +%s` ]; do - echo -ne "$(date -u --date @$(($date2 - `date +%s` )) +%H:%M:%S)\r"; + date2=$(($(date +%s) + pseconds)) + while [ "$date2" -ge "$(date +%s)" ]; do + echo -ne "$(date -u --date @$((date2 - $(date +%s))) +%H:%M:%S)\r" done notify-send "Work" "Time to get back to work"; read -n1 -rsp $'Press any key to continue or Ctrl+C to exit...\n'; done else echo -ne "Your OS is currently not supported\n"; -fi \ No newline at end of file +fi From d68b43b3bb5c51428e2d080aafa50876dc7fd4f7 Mon Sep 17 00:00:00 2001 From: salad Date: Wed, 19 Nov 2025 14:23:07 +0000 Subject: [PATCH 2/2] Additional helpful information regarding usage parameters --- scripts/pomodoro.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/scripts/pomodoro.sh b/scripts/pomodoro.sh index f070c4a..25ae4a1 100755 --- a/scripts/pomodoro.sh +++ b/scripts/pomodoro.sh @@ -8,6 +8,26 @@ wseconds="${1:-25}*60"; pseconds="${2:-wseconds/300}*60"; +usage() +{ + echo "Usage: $0 {focus time length} {break length}" + echo "Times given should be integers representing minutes" + echo "Defaults: focus time length = 25 minutes" + echo " break time length = 5 minutes" +} + +if [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ "$#" -gt 2 ]; then + echo "The Pomodoro Technique is a time management method developed by Francesco Cirillo in the late 1980s." + usage + exit 0 +fi + +integers='^[0-9]+$' +if ! [[ "$1" =~ $integers ]] || ! [[ "$2" =~ $integers ]]; then + usage + exit 1 +fi + # Check os and behave accordingly if [ "$(uname)" == "Darwin" ]; then while true; do