#!/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