# The Poor Man's Growl Bridge

In case you're interested in writing portable Perl and Python scripts that can be deployed anywhere and use Growl with minimal hassle (i.e., without installing all the extra bridging crud), this bit of Python code works fine for me:

import os

APPLESCRIPT = "/usr/bin/osascript"

def notify(title, description, icon = "Finder"):
# see if we're on a Mac
if os.path.exists(APPLESCRIPT):
# See if Growl is installed
if os.path.exists("/Library/Frameworks/GrowlAppBridge.framework"):
applescript = os.popen(APPLESCRIPT, 'w')
applescript.write( 'tell application "GrowlHelperApp"\n' +
'notify with title "%s" description "%s" icon of application "%s"\n' %
(title, description, icon) + 'end tell')
applescript.close()
else:
# use something else here, or edit the if clauses to fall straight down
pass
else:
# use the age old UNIX way
print "NOTIFICATION - %s: %s" % (title, description)

if __name__ == '__main__':
notify( "Python", "Poor man's Growl bridge using piping" )

(The Perl version is left as an exercise to the readers - after all, it's trivial to port, and each Perl geek will want to do it their own way...)

Of course, I've barely scratched the surface - but if you're anything like me and hate depending on any one platform, this should be easy enough to graft into your own scripts.

## Arrrrrrr!

That's my little contribution to Talk Like a Pirate Day. I've got a busy Sunday ahead, so if you want to see the whole front page in pirate talk, it be here.