AppleScript Support for Growl

Script Editor

About AppleScript Support

AppleScript support is built into Growl; nothing special needs to be done to enable it.

A Note on AppleScript changes in Growl 0.6

You must update your existing AppleScripts for Growl 0.6 In Growl 0.6 AppleScripts must register their notifications every time the script is run — unregistered notifications will not be displayed. See below for an example of registration.

Usage

Basics

To send a Growl notification via AppleScript, you talk to GrowlHelperApp using two commands: register and notify. A script, like an application, must register itself (once, though multiple times is harmless) with Growl before sending any notifications. The full syntax of the register and notify commands can be viewed by opening Script Editor, choosing File → Open Dictionary, and selecting GrowlHelperApp from the list.

Sample AppleScript Notification

tell application "GrowlHelperApp"
 -- Make a list of all the notification types 
 -- that this script will ever send:
 set the allNotificationsList to ¬
  {"Test Notification" , "Another Test Notification"}

 -- Make a list of the notifications 
 -- that will be enabled by default.      
 -- Those not enabled by default can be enabled later 
 -- in the 'Applications' tab of the growl prefpane.
 set the enabledNotificationsList to ¬
  {"Test Notification"}

 -- Register our script with growl.
 -- You can optionally (as here) set a default icon 
 -- for this script's notifications.
 register as application "Growl AppleScript Sample" ¬
   all notifications allNotificationsList ¬
   default notifications enabledNotificationsList ¬
   icon of application "Script Editor"
	 
 --	Send a Notification...
 notify with name "Test Notification" ¬
   title "Test Notification" ¬
   description "This is a test AppleScript notification." ¬
   application name "Growl AppleScript Sample" 

 notify with name "Another Test Notification" ¬
   title "Another Test Notification :) " ¬ 
   description "Alas — you won't see me until you enable me..." ¬
   application name "Growl AppleScript Sample" 

end tell

Once you send the Registration command - your script will appear in the 'applications' tab of the Growl prefpane.

AppleScript Registration

Download Sample Script

Notifications Using Images

Growl's notify command supports four types of images for notification when using AppleScript:

Notes on File Paths

For the "notify ... image from location" and "notify ... icon of file" commands Growl accepts any of the following types as 'locations':

Checking if Growl is running

If you want to distribute your scripts, you should check if Growl is running before sending any events to GrowlHelperApp in order to avoid the "Choose Application" dialog.


tell application "System Events"
	set isRunning to ¬
		count of (every process whose name is "GrowlHelperApp") > 0
end tell

Authors

v0.6 (update) — Diggory Laycock — www.monkeyfood.com

v0.5 — Adam Nolley — nanovivid.com

Website hosted by James Cox