Create a gist now

Instantly share code, notes, and snippets.

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