Skip to content

Instantly share code, notes, and snippets.

@joshcarr
Created July 25, 2013 01:06
Show Gist options
  • Save joshcarr/6076055 to your computer and use it in GitHub Desktop.
Save joshcarr/6076055 to your computer and use it in GitHub Desktop.
Runs script, and prints a notification with growl when it finishes
#!/bin/sh
#
# Runs script, and prints a notification with growl when it finishes
#
# Written sometime in 2006, posted 2007/08
#
# With Tips from Ranger Rick, Tim Bunce and Ruben Fonseca
#
# Run the command, including arguments with spaces
"$@"
status=$?
# decide which status to use
if [ "$status" == "0" ] ; then
result="completed"
else
result="FAILED ($status)"
fi
# decide which notifier we have
env growlnotify -h > /dev/null 2> /dev/null
has_growl=$?
env notify-send -? > /dev/null 2> /dev/null
has_libnotify=$?
# notify the user, growl or libnotify
if [ "$has_growl" == "0" ] ; then
growlnotify -m "Script '$@' $result" -s "Background script notification" &
elif [ "$has_libnotify" == "0" ] ; then
notify-send "Script '$@' $result" "Background script notification" &
fi
# exit with the original status
exit $status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment