Teach iTunes to Growl on Command

Update: Changed the script to make the formatting better and include the album art of the track. Thanks to Freek in the comments below for a couple of ideas. The track info is copied directly from his comments, and I didn’t yet get a chance to reformat that — maybe soon…

Haven’t posted anything useful here for a while so I thought I’d put something together today and post it — something that I’ve wanted for a while. Occasionally when I want to zone out at work I just put iTunes in random, hide it, and go. Unfortunately, I end up wasting time flipping iTunes open and then hiding it again when I can’t remember a track name or artist or album. I’ve been meaning to put together something to use in Quicksilver to enable being able to take a peek at what is playing, namely using the OSX system extension Growl. Download this:

PlasticWare Downloadable ::
Growl Track Info (Oct. 21, 2007)
Download (~3,645 bytes) :: growl_track_info.zip

I can’t remember why I have Growl on my system, that is, what application or system version first installed it, so if you don’t have Growl, you can find it here: http://growl.info/. Basically, if you aren’t familiar with it, Growl allows for (sometimes annoying) pop-up bubbles that can notify you of things going on with applications that are currently not in the foreground (for example, when an upload completes in Transmit, or when you get an incoming message in Adium or iChat).Once you’ve installed Growl (or check to see if it exists in your System Prefs), download the script linked above, unzip it, and place it in your iTunes scripts folder (/Users/~YourUserName/Library/iTunes/Scripts). Now, if you restart iTunes, the script should show up in your iTunes applescript menu, and you can choose the script and see that it triggers the Growl pop-up — which really isn’t terribly interesting since you are already staring at iTunes anyway.

Now, assuming that you have Quicksilver installed on your system, you can add a custom trigger as seen below.


To add the trigger, open Quicksilver and go to Catalog. Select Modules and make sure that you have the iTunes module showing there. If not, you need to enable the iTunes module. Click the circle arrow thing on the bottom right to rescan your catalog - you may notice that the count for the iTunes applescripts increases by 1. Next, select Triggers, and then select Custom Triggers. Find the little plus sign button at the middle bottom and choose HotKey. This will slide open a Quicksilver selector thing, whatever it’s called. You can now type part of “growl track info” the same way as you would normally using Quicksilver, and select the Applescript “Growl Track Info.scpt” where it shows up in the list; it will default to Run as the action, which is fine. Now double click the line in the Trigger column on the right and set up your hotkey for On Press (my friends make fun of me for choosing something like Control-Option-Command-Shift-I so I can just mash the bottom left of the keyboard and one other letter and not interfere with other application keystrokes, but if you do that I won’t make fun of you). You should now be able to hide iTunes and use the Quicksilver trigger to see whats playing in iTunes, as well as control iTunes with the rest of the iTunes module available for Quicksilver, and free up whatever corner of your screen you were keeping the mini player before.

10 Comments

  1. Freek
    Posted March 20, 2007 at 5:13 am | Permalink

    nice idea but sadly it makes my macbook freeze up (well be really slow and make the app crash so i have to use force quit) if i try to start it (in itunes applescript menu) or even open it in scripteditor

  2. Freek
    Posted March 24, 2007 at 6:54 am | Permalink

    Hmm i got it to work now! very nice thanks. One suggestion for improvement: on digital radio station it lists station name instead of track name

  3. Freek
    Posted March 24, 2007 at 7:34 am | Permalink

    tell application “System Events” to if (application processes whose name is “iTunes”) is not {} then
    tell application “iTunes”
    if player state is playing then
    set trk_arts to the artist of the current track
    set trk_name to the name of the current track
    set trk_albm to the album of the current track
    set trk_num to the track number of the current track
    set trk_desc to (trk_arts & ”
    ” & trk_albm)
    if current stream title is not missing value then set trk_desc to current stream title as string
    else
    set trk_name to (”iTunes Status”)
    set trk_desc to (”iTunes not playing.”)
    end if
    end tell
    tell application “GrowlHelperApp”
    set the allNotificationsList to ¬
    {”Show Status”}
    set the enabledNotificationsList to ¬
    {”Show Status”}
    register as application ¬
    “Quicksilver” all notifications allNotificationsList ¬
    default notifications enabledNotificationsList ¬
    icon of application “iTunes”
    notify with name “Show Status” title trk_name description trk_desc application name “Quicksilver”
    end tell
    end if

  4. Freek
    Posted March 24, 2007 at 7:35 am | Permalink

    errr sorry… anyway, this script also works for streams
    tell application "System Events" to if (application processes whose name is "iTunes") is not {} then
    tell application "iTunes"
    if player state is playing then
    set trk_arts to the artist of the current track
    set trk_name to the name of the current track
    set trk_albm to the album of the current track
    set trk_num to the track number of the current track
    set trk_desc to (trk_arts & "
    " & trk_albm)
    if current stream title is not missing value then set trk_desc to current stream title as string
    else
    set trk_name to ("iTunes Status")
    set trk_desc to ("iTunes not playing.")
    end if
    end tell
    tell application "GrowlHelperApp"
    set the allNotificationsList to ¬
    {"Show Status"}
    set the enabledNotificationsList to ¬
    {"Show Status"}
    register as application ¬
    "Quicksilver" all notifications allNotificationsList ¬
    default notifications enabledNotificationsList ¬
    icon of application "iTunes"
    notify with name "Show Status" title trk_name description trk_desc application name "Quicksilver"
    end tell
    end if

  5. Freek
    Posted March 24, 2007 at 7:35 am | Permalink

    hmm still not right… please delete other two posts…

  6. Freek
    Posted March 24, 2007 at 7:36 am | Permalink

    eventually i will get it right

    tell application “System Events” to if (application processes whose name is “iTunes”) is not {} then
    tell application “iTunes”
    if player state is playing then
    set trk_arts to the artist of the current track
    set trk_name to the name of the current track
    set trk_albm to the album of the current track
    set trk_num to the track number of the current track
    set trk_desc to (trk_arts & ”
    ” & trk_albm)
    if current stream title is not missing value then set trk_desc to current stream title as string
    else
    set trk_name to (”iTunes Status”)
    set trk_desc to (”iTunes not playing.”)
    end if
    end tell
    tell application “GrowlHelperApp”
    set the allNotificationsList to ¬
    {”Show Status”}
    set the enabledNotificationsList to ¬
    {”Show Status”}
    register as application ¬
    “Quicksilver” all notifications allNotificationsList ¬
    default notifications enabledNotificationsList ¬
    icon of application “iTunes”
    notify with name “Show Status” title trk_name description trk_desc application name “Quicksilver”
    end tell
    end if

  7. Posted June 20, 2007 at 7:26 am | Permalink

    I was just thinking about writing a script like this, and then I thought, “Hey, I bet someone else has had this issue in the past” and Googled and found you. Thanks for the script!

  8. Posted June 20, 2007 at 9:22 am | Permalink

    Cool. Glad to know it. Freek above had some good ideas as well. The script is pretty raw, but its definitely a good start to get you going (or maybe just an ends in itself).

  9. Posted June 21, 2007 at 5:38 am | Permalink

    Ryan, I made some changes to the script and posted a modified version on my site.

    Basically, I switched to using the album artwork and adjusted the formatting of the notification to suit my own taste.

    Thanks again!

  10. Lennart Borregaard
    Posted August 10, 2007 at 7:28 am | Permalink

    I found a script that includes the album cover, but it’s very slow - it can take up to 5 seconds before the notifications slows because it has to convert the cover… anyone got a quick script with cover?

One Trackback

  1. [...] As any good scripter does before setting out to write his own, I went to Google. Sure enough Ryan Todd of plasticstare.com had written a script to do just that. [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*