Created
November 28, 2015 01:10
-
-
Save kevinhughes27/26bfe9dd408972c581f7 to your computer and use it in GitHub Desktop.
A simple program to display a warning message if I have been coding for more than 90 mins
This file contains hidden or 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
#!/usr/bin/env bash | |
# add to cron tab | |
# crontab -e | |
# then append: | |
# */30 * * * * /home/kevin/coding-timer.sh | |
# need to have: | |
# xhost local:mpromber > /dev/null | |
# in bashrc | |
# fetch the pid of my editor process | |
pids=($(pgrep atom)) | |
pid=${pids[0]} | |
if [[ -z "$pid" ]]; then | |
echo "atom proccess not found" | |
exit | |
fi | |
uptime=$(ps -p "$pid" -o etimes=) | |
mins=$((uptime / 60)) | |
if [[ $mins -gt 90 ]]; then | |
zenity --warning --text="you've been coding for $mins minutes" --display=:0.0 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment