add old z-eyes.sh

This commit is contained in:
Julin S 2023-05-18 11:51:20 +05:30
parent 34f32a5b85
commit c1ee46171e
1 changed files with 46 additions and 0 deletions

46
z-eyes.sh Normal file
View File

@ -0,0 +1,46 @@
#!/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