Last active
January 30, 2022 14:02
-
-
Save adrianlshaw/e34a40d8d1da6f42968c79eaa794f1eb to your computer and use it in GitHub Desktop.
Pop up reminder to get up every 20 mins and look outside for 20 seconds
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 | |
# Put this in /etc/cron.d/ | |
# Install using `crontab -e` and add the following line | |
# */20 * * * * export DISPLAY=:0 && /etc/cron.d/takeabreak | |
if [[ $(date +"%H") -gt 18 ]]; then | |
echo End of work day. Not going to pop up. | |
exit 0 | |
fi | |
WEBCAM_IN_USE=$(lsmod | grep uvcvideo | head --lines=1 | awk '{ print $3 }') | |
if [[ $WEBCAM_IN_USE -gt 0 ]]; then | |
echo Webcam on | |
exit 0 | |
fi | |
HOSTING_ZOOM=$(ps aux | grep "aomhost" | grep -v grep | wc -l) | |
if [[ $HOSTING_ZOOM -ne 0 ]]; then | |
echo Hosting zoom | |
exit 0 | |
fi | |
#SCREENSAVER_ON=$(ps aux | grep gsd-screensaver-proxy | wc -l) | |
#if [[ $SCREENSAVER_ON -ne 0 ]]; then | |
# echo Screensaver on | |
# exit 0 | |
#fi | |
zenity --question --text="Take a break. Look outside around 20 feet for 20 seconds" --display=:0.0 | |
RESULT=$? | |
if [[ $RESULT -eq 0 ]]; then | |
echo Said yes | |
counter=0 | |
while [ "$counter" -le 100 ]; do | |
sleep 1 | |
counter=$(( $counter + 5)) | |
echo $counter | |
done | zenity --progress --title="$name" --text="Break in progress" --percentage=0 --auto-close --display=:0.0 | |
else | |
echo Snoozing | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment