Skip to content

Instantly share code, notes, and snippets.

@kevinhughes27
Created November 28, 2015 01:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinhughes27/26bfe9dd408972c581f7 to your computer and use it in GitHub Desktop.
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
#!/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