Growl Support

Talk, speculate, discuss, pontificate. As long as it pertains to Hazel.

Moderators: Mr_Noodle, Moderators

Growl Support Wed Oct 11, 2006 3:03 pm • by Robb
I really like this app and think it has great potential. I think growl support could be a really useful feature for it.

here is the like for more info.

h**p://growl.info/

Regards, Robb :D
Robb
 
Posts: 1
Joined: Wed Oct 11, 2006 2:51 pm

Wed Oct 11, 2006 4:44 pm • by Mr_Noodle
Growl support is already in the feature database. Once I get 1.1 out (which is imminent) then I'll start finalizing the feature list for 1.2 (Growl is pretty high up on the list).

Thanks.
Mr_Noodle
Site Admin
 
Posts: 8427
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Fri Feb 09, 2007 8:49 pm • by IDontDoWindows
Hazel supports Applescript and so does Growl. Depending upon what you want to accomplish, you might not need to wait for the next version.
IDontDoWindows
 
Posts: 57
Joined: Sun Jan 07, 2007 5:43 am

Fri Mar 02, 2007 1:30 am • by Halleck
I decided to give this a try in applescript even though I'm pretty new to it. Here's what I came up with (note: NOT FUNCTIONING):
http://eliot.bambi.net/dump/hacks/osx/G ... -alpha.zip

I can't find a mechanism with which Hazel can pass stuff (like strings for description text) to a script, so I had to make a script for each type of notification. They all share the same growl library but contain different strings.

When run normally, these scripts behave fine. For some reason, when invoked by Hazel, nothing happens.

This is a poor solution anyway (not quite as bad as, say, using a shell script to invoke growlnotify) but I figured I'd post it in case anyone wanted to tinker.

P.S., if you plan on running these make sure that the scriptdir property is set to the correct location for GrowlNotify.scpt (defaults to ~/Dev/scripts)
Halleck
 
Posts: 1
Joined: Fri Mar 02, 2007 12:17 am

Tue Mar 20, 2007 7:42 pm • by IDontDoWindows
I just wanted you to know that I got the files and haven't had time to work on them yet. I hope to get a solution to you soon.
IDontDoWindows
 
Posts: 57
Joined: Sun Jan 07, 2007 5:43 am

Tue Mar 20, 2007 9:51 pm • by Mr_Noodle
Just an FYI that the 2.0 alpha version has Growl support. If you're comfortable with trying out pre-release software go check out the beta forum.
Mr_Noodle
Site Admin
 
Posts: 8427
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Wed Mar 21, 2007 4:42 pm • by IDontDoWindows
Not that comfortable with pre-relases. Maybe beta, but not alpha, and really squeamish about pre-alphas. But thanks for the offer.
IDontDoWindows
 
Posts: 57
Joined: Sun Jan 07, 2007 5:43 am

Finally! Sat Jul 07, 2007 8:57 pm • by IDontDoWindows
I knew I was procrastinating, but I didn't realize it had been 4 months. Apologies for the delay; I was way intimidated by your script. After I finally got around to tackling it, I found it was much easier than I anticipated.

You're right, there has to be 2 scripts for what you want (at least as far as I know). I've got other notes in there as well.

The main script:
Code: Select all
property programName : "Hazel"
global notifysys
set notifysys to "growl"

(* you only need to run init once. once you register an app with growl, it stays. in case you give the script to someone else, or you reinstall your system, whatever, the following checks that "Hazel" is registered with growl, and if it isn't, runs init.

Every registered app has a .growlticket file in the Tickets folder, so I have Finder searching for Hazel's growlticket.*)

tell application "Finder"
   -- is growl running?
   if (name of processes) contains "GrowlHelperApp" then
      -- if "hazel" hasn't been registered with growl, run init to do so
      if not (exists file "Hazel.growlTicket" of folder "Tickets" of folder "Growl" of (path to application support from user domain)) then my init()
   else
      -- if growl isn't running, resort to dialogs
      set notifysys to "dialog"
   end if
end tell

on notify(ntype, ntitle, ntext)
   if notifysys is "growl" then
      tell application "GrowlHelperApp"
         notify with name ntype title ntitle description ntext application name programName
      end tell
   else
      (* this gets annoying. you'll be working in another program and finder will come to the front to let you know the file has moved. you can take out the "activate" line, but then the finder icon is going to jump in the dock until you switch and  acknowledge the dialog (yes, even though it's supposed to give up after 4 secs). personally, i'd suggest giving up the dialog notifications. *)
      tell application "Finder"
         activate
         -- YOU NEED TO DESIGNATE THE WHERE THE HAZELHELPER ICONS CAN BE FOUND. I used icons2icns to get the icons from the HazelHelper app and save it to a icns file. You can save the script as a bundle, if you want, and put the icns file in the bundle. But again, the dialogs are a pain in the butt, so I'd forego all that if I were you.
         display dialog ntext buttons ("Okay") default button 1 with title ntitle with icon alias "R2D2:Users:me:Desktop:HazelHelper.icns" giving up after 4
      end tell
   end if
end notify

on init()
   tell application "GrowlHelperApp"
      set allNotificationsList to {"Items Labeled", "Items Moved", "Items Trashed"}
      register as application programName all notifications allNotificationsList default notifications allNotificationsList icon of application "HazelHelper.app"
   end tell
end init


The script Hazel runs:
Code: Select all
on hazelProcessFile(theFile)
   -- change file designations as necessary
   set pathToScript to (path to desktop as string) & "mainscript.scpt"
   
   set GrowlNotify to (load script file pathToScript)
   
   (* this tell block isn't necessary. you can delete it and stick with the generic "Item has been moved"*)
   tell application "Finder" to set theFileName to name of theFile as string
   
   tell GrowlNotify
      run
      notify("Items Moved", "Items Moved", theFileName & " has been moved.")
   end tell
end hazelProcessFile
IDontDoWindows
 
Posts: 57
Joined: Sun Jan 07, 2007 5:43 am

Sat Jul 07, 2007 10:21 pm • by IDontDoWindows
I forgot the last script: turning Growl on when it's off. So you can delete that whole section about doing dialog boxes instead of Growl.

Code: Select all
tell application "Finder"
   set growlLoc to "PreferencePanes:Growl.prefpane"
   
   -- where is growl? in computer library folder or user library folder? wherever the hell it is, open it (& start it)
   if exists file ((path to library folder from local domain as string) & growlLoc) then
      open file ((path to library folder from local domain as string) & growlLoc)
   else
      if exists file ((path to library folder from user domain as string) & growlLoc) then open file ((path to library folder from user domain as string) & growlLoc)
   end if
   
end tell
IDontDoWindows
 
Posts: 57
Joined: Sun Jan 07, 2007 5:43 am

Sat Jul 07, 2007 11:34 pm • by IDontDoWindows
I've posted a generic version of the script in Tips & Tricks for everyone else.
IDontDoWindows
 
Posts: 57
Joined: Sun Jan 07, 2007 5:43 am


Return to Open Discussion