1

I need a way to trigger a Growl notification when a Beep is triggered in the Terminal.

Ideally, I 'd love to have a way to capture the terminal output - from an SSH server let's say - and handle it using Growl - conditionally.

Any ideas?

4 Answers 4

1

An interesting question, but fairly open-ended. What sorts of beeps are you trying to capture? And what output are you trying to handle? Errors? Completion of processes?

growlnotify is the command-line tool to post Growl notifications. It has to be installed separately, and can be found in the Extras folder on the Growl disk image.

You could use the unix trap command to trap any errors in a script and send output to growl using growlnotify. I'm not aware of any way to trap the terminal bell, you have to trap for some specific unix signal.

To see what signals are available on your system, type kill -l into the terminal. The above-linked article on the unix trap command has a list of common trap signals.

If you're looking for a way to notify with growl the completetion of a long-running terminal script, here's a solution on Mac OS X Hints.

If you just want to redirect all terminal output to growl, the technique on Mac OS X Hints could be modified for this. Put this in your .profile, .bashrc or .zshrc. It will redirect your command output to growl.

# Before a command execution
preexec() {
   export PREEXEC_CMD="Command: $1"
   $1 | growlnotify -n "Terminal" ${PREEXEC_CMD:-Some command}
}

I'll leave it as an exercise to the reader to add logic to redirect conditionally depending on command or whatever parameters, as I'm unaware as to what "conditions" you're looking for. :)

1

What you want is possible, but I don't think the tool exists yet. As a place to start developing it yourself, check out BounceTerm (comes with source) which turns beeps and bells into dock bounces. Seems to be the exact behavior you seek but with a slightly different output.

1

Use iTerm as your terminal emulator, its the only way I know of. It has growl support :)

0

A partial answer: As of Mac OS X Lion 10.7, Terminal displays a badge on its Dock icon indicating the number of BELs written in inactive terminals. "Inactive" means either the terminal window isn't the front/active window, or the terminal isn't the selected tab in a multi-tab window. It also displays a "bell" icon in tabs to indicate which terminal beeped (I recommend showing the tab bar even when you're not using multi-tab windows—Lion Terminal displays a number of useful new status indicators there). If Terminal isn't the front application, it will also bounce its Dock icon when beeping.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .