![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Context here is that I'm trying to abandon ship on Quicksilver on account of its oldness, staleness, and general decrepitude, but since I used it for such a weird variety of stuff, I'm having to get a little creative on how to replace it. In this case, I'd rigged QS to throw a Growl alert describing the currently playing track in iTunes whenever I whacked a certain hotkey, and since I wasn't interested in running a whole extra app just for that, I figured I could probably roll my own thingamabob and trigger it with FastScripts.
I figured right! And here's the goods:
tell application "iTunes"
set trackName to name of current track
set trackArtist to artist of current track
set trackAlbum to album of current track
set trackRating to rating of current track
if artworks of current track is not {} then
set trackArtwork to the data of artwork 1 of current track
set hasArtwork to true
else
set hasArtwork to false
end if
end tell
tell application "GrowlHelperApp"
(* register as application "iTunes Track Alert" all notifications {"Current Track"} default notifications {"Current Track"} icon of application "iTunes" *)
if hasArtwork is true then
notify with name "Current Track" title trackArtist & " – " & trackName description trackArtist & " – " & trackAlbum & " – " & trackName & " (" & (trackRating / 20 as integer) & "★)" application name "iTunes Track Alert" pictImage trackArtwork
else
notify with name "Current Track" title trackArtist & " – " & trackName description trackArtist & " – " & trackAlbum & " – " & trackName & " (" & (trackRating / 20 as integer) & "★)" application name "iTunes Track Alert"
end if
end tell
For reasons that are somewhat complicated, you'll have to paste that into AppleScript Editor and save it, then uncomment that one line, run the script a single time, and close the file without saving. After that, it'll work just fine, and you can set the display options for the alert in Growl's preference pane; the name of the application will be "iTunes Track Alert."
(Yes, I could have just left that line uncommented and skipped that extra step, but that seemed to make it run slower when I was testing it, and it really does only have to happen once.)
Incidentally, my hacked-up-in-an-afternoon-bullshit-AppleScript replacement for this feature turns out to be better than Quicksilver's version, because it shows the artwork even when it's not embedded in the file and can display the track's rating. Take that!