Skip to content

Instantly share code, notes, and snippets.

@blurrcat
Created August 21, 2017 07:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blurrcat/e875dba2281394cad5ce067a88abb854 to your computer and use it in GitHub Desktop.
Save blurrcat/e875dba2281394cad5ce067a88abb854 to your computer and use it in GitHub Desktop.
Remind you to take a break from work once in a while
#!/bin/bash
# Remind you to take a 10-min break every 50 min.
# It will send a notification and speak on OSX. On other platform, it just prints a message in the console..
user=`whoami`
worktime=3000
breaktime=570
backtime=30
function notify {
which osascript > /dev/null && osascript -e "display notification \"$1\" with title \"Mr. Tomato\" subtitle \"$2\""
printf "[%s]%s\n" "$(date +%H:%M:%S)" "$1"
which say > /dev/null && say "$1"
}
trap 'notify "Have a nice day, bye bye." "Bye"; exit' INT
notify "Greetings $user! I'm the tomato. My job is to remind you to take a break from work once in a while. Let's get started!" "Hi"
sleep 0.5
while true
do
notify "Start working you lazy bastard!" "Work, Work"
sleep $worktime
notify "It's time to have a rest, baby. Go have fun for 10 minutes." "Take a break"
sleep $breaktime
notify "Hey $user, it's time to get back to work." "Back to work"
sleep $backtime
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment