47 lines
1.2 KiB
Bash
47 lines
1.2 KiB
Bash
#!/bin/bash
|
|
|
|
# # z-eyes
|
|
#
|
|
# A simple script using zenity to remind you to take breaks for giving your eyes some rest while using computers.
|
|
#
|
|
# The idea is to look away from the monitor for 20 seconds after every 20 minutes.
|
|
|
|
|
|
REST_TIME=20m
|
|
DISTANT_STARE_TIME=20
|
|
|
|
# Got to redirect stderr of zenity to /dev/null.
|
|
# Otherwise error message about lack of parent window
|
|
# will show up in the terminal
|
|
|
|
function show_progress_bar {
|
|
# equiv of 20s because 1s per iterations as there are
|
|
# 20 iterations for this loop.
|
|
for i in {0..100..5}
|
|
do
|
|
echo "$i"
|
|
sleep $DISTANT_STARE_TIME / 20
|
|
done |
|
|
zenity --title='z-eyes' \
|
|
--text='Look 20 feet away for 20 seconds' \
|
|
--progress --auto-close 2> /dev/null
|
|
|
|
if [ "$?" -eq 0 ]
|
|
then
|
|
# Didn't cancel
|
|
zenity --notification --text "20 seconds is up." 2> /dev/null
|
|
else # Cancelled
|
|
zenity --notification \
|
|
--text "20 seconds was not completed." 2> /dev/null
|
|
fi
|
|
}
|
|
|
|
while true
|
|
do
|
|
sleep "$REST_TIME" && \
|
|
zenity --info --text "Your eyes are tired. Rest?" \
|
|
--title="z-eyes" 2> /dev/null
|
|
|
|
show_progress_bar
|
|
done
|