Skip to content

Instantly share code, notes, and snippets.

@saml
Created December 12, 2018 19:21
Show Gist options
  • Select an option

  • Save saml/fba41acc7aa56e6bed567342064e035b to your computer and use it in GitHub Desktop.

Select an option

Save saml/fba41acc7aa56e6bed567342064e035b to your computer and use it in GitHub Desktop.
#!/bin/bash
prog="$(basename "$0")"
count="$(pkill --signal 0 -c "$prog")"
if [[ "$count" = "1" ]]
then
notify-send 'I will notify you after 20 mins'
sleep $(( 20 * 60 ))
notify-send -u critical 'Look away for 20 seconds'
else
duration=$(ps aux|grep "$prog"|grep -v grep|awk '{print $9}')
notify-send "Already running $duration"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment