roadrunnertwice: A roadrunner *actually running on a road.* (Roadrunner - Going faster miles an hour)
[personal profile] roadrunnertwice
I learned how to talk to Growl today! Hello, Growl.

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!
From:
Anonymous (will be screened)
OpenID (will be screened if not validated)
Identity URL: 
User
Account name:
Password:
If you don't have an account you can create one now.
Subject:
HTML doesn't work in the subject.

Message:

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org


 
Notice: This account is set to log the IP addresses of everyone who comments.
Links will be displayed as unclickable URLs to help prevent spam.

Profile

roadrunnertwice: Vesta Tilley, Victorian drag king (Default)
Nick Eff

May 2017

S M T W T F S
 123456
7 8910111213
14151617181920
21222324252627
28293031   

Expand Cut Tags

No cut tags

Most Popular Tags

Static and Noise

If you pass the rabid child, say "hammer down" for me.

The Fell Types are digitally reproduced by Igino Marini.

Style Credit