sticky applescript notifications

The Growl forums have moved to Google Groups, this forum is read only.
dfabulich
Harmless
Posts: 3
Joined: Mon Jul 14, 2008 9:03 pm

sticky applescript notifications

Postby dfabulich » Mon Jul 14, 2008 9:09 pm

The Growl bridge has an "isSticky" option that allows you to make notifications that don't automatically fade away. I'd like to do that in an AppleScript I'm writing, but I can't figure out how to do it. The documentation here doesn't appear to have an example: http://growl.info/documentation/applescript-support.php

Can anyone give me an example of AppleScript that sends a sticky notification?

User avatar
Diggory
Growl Team
Posts: 129
Joined: Sat Dec 04, 2004 12:17 pm
Location: London

Re: sticky applescript notifications

Postby Diggory » Mon Jul 14, 2008 9:46 pm

If you look at the scripting dictionary for GrowlHelperApp you will see that there is an optional boolean 'sticky' property:

Code: Select all

Growl Suite   AppleScript for the Growl Notification System
notify v : Post a notification to be displayed via Growl
notify
with name text : name of the notification to display
title text : title of the notification to display
description text : full text of the notification to display
application name text : name of the application posting the notification.
[image from location location specifier] : Location of the image file to use for this notification. Accepts aliases, paths and file:/// URLs.
[icon of file location specifier] : Location of the file whose icon should be used as the image for this notification. Accepts aliases, paths and file:/// URLs. e.g. 'file:///Applications'.
[icon of application text] : Name of the application whose icon should be used for this notification. For example, 'Mail.app'.
[image Image] : TIFF Image to be used for the notification.
[pictImage Picture] : PICT Image to be used for the notification.
[sticky boolean] : whether or not the notification displayed should time out. Defaults to 'no'.
[priority integer] : The priority of the notification, from -2 (low) to 0 (normal) to 2 (emergency).
[identifier text] : The identifier of the notification for coalescing.
register v : Register an application with Growl
register
as application text : name of the application as which to register.
all notifications list of text : list of all notifications to register.
default notifications list of text : list of default notifications to register.
[icon of application text] : Name of the application whose icon should be used for this notification. For example, 'Mail.app'.
Picture n
Image n



So you could easily modify a sample script to the following:

Code: Select all

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 (Which is Sticky)" ¬
   description "This is a test AppleScript notification.  It is sticky" ¬
   application name "Growl AppleScript Sample"  sticky yes
 


 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


Return to “Growl”

Who is online

Users browsing this forum: No registered users