Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # The script reminds to take breaks. It checks the uptime and the
- # current time and depending on their values opens a notification
- # window saying either to turn off the computer or to exercise;
- # alternatively it just beeps. The script is started as a cron job
- # every half an hour, so an appropriate entry should be created. The
- # script uses espeak, yad, uptime, date, sox and a GTK icon set; so
- # they should be installed on the machine.
- function announcement()
- {
- espeak -v english "$1" &
- yad --notification --image="$2"
- yad --title="Break!" --text="$3" --image="$4" --borders=8 --width=256 --button='Dismiss!gtk-cancel'
- exit 0
- }
- hours_of_uptime=$(uptime -p | cut -d ' ' -f 2)
- minutes_of_uptime=$(uptime -p | cut -d ' ' -f 4)
- if (("$hours_of_uptime" % 3 == 0)) && (("$minutes_of_uptime" < 30)); then
- announcement "Relax!" "emblem-colors-red" "Turn off the computer!" "exit"
- fi
- current_hour=$(date +%H)
- hours_no_leading_zeros=${current_hour#0}
- current_minute=$(date +%M)
- minutes_no_leading_zeros=${current_minute#0}
- total_minutes=$((minutes_no_leading_zeros + hours_no_leading_zeros * 60))
- if ((total_minutes % 90 == 0)); then
- announcement "Exercise!" "emblem-colors-yellow" "Exercise!" "applications-sports"
- fi
- play -n synth 0.05 sine 220 vol -20dB
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement