Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Use Growl to monitor long-running shell commands' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Use Growl to monitor long-running shell commands
Authored by: Anonymous on Oct 11, '07 09:31:24PM
This seems like it could be annoying, triggering when you don't want it (Commands like "less" can run for over 10 seconds, and I couldn't care less when it exits)

Instead of blacklisting or whitelisting applications, I found a little script ages you call like:
gnotif gzip -9 somefile.tar

Then when it completes, it creates a growl notification. It's similar to the 'time' command, you prepend it when you want to know how long a command takes.

I've saved it to /usr/local/bin/ called 'gnotif'

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


[ Reply to This | # ]
Use Growl to monitor long-running shell commands
Authored by: Lutin on Oct 12, '07 04:34:56AM

I had implemented your solution before reading this hint.
Unfortunately, I often realize a command will take longer than expected once it's already running (like a slow server with wget...).

The idea in the hint is really great.
Each reader will pick what he prefers. And both hints aren't exclusive (but you might want to add some code to prevent a double notification).



[ Reply to This | # ]
Use Growl to monitor long-running shell commands
Authored by: 4ndrew on Oct 13, '07 02:23:00PM