Created
November 20, 2019 01:48
-
-
Save dasm/6fa8f8e4025227fabf40c8313139fcc5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Based on Kiailandi (https://github.com/kiailandi) | |
set -e | |
minutes=${1:-25} | |
countdown() { | |
seconds=$1 | |
date=$((`date +%s` +$seconds)); | |
echo $2: `date` | |
while [ "$date" -gt `date +%s` ]; do | |
echo -ne "$(date -u -j -f %s $(($date - `date +%s`)) +%H:%M:%S)\r"; | |
sleep 1 | |
done | |
afplay /System/Library/Sounds/Funk.aiff | |
osascript >/dev/null << EOF | |
display dialog "Stop $2." with title "$2" buttons {"OK"} | |
EOF | |
} | |
# Check os and behave accordingly | |
if [ "$(uname)" == "Darwin" ]; then | |
while true; do | |
countdown $(echo $minutes | awk -F: '{ print ($1 * 60) }') "Work :" | |
countdown $(echo $minutes | awk -F: '{ print ($1 * 12) }') "Break:" | |
done | |
elif [ "$(expr substr $(uname -s) 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"; | |
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"; | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment