Skip to content

Instantly share code, notes, and snippets.

@oskarhagberg
Created December 5, 2009 07:27
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save oskarhagberg/249602 to your computer and use it in GitHub Desktop.
Save oskarhagberg/249602 to your computer and use it in GitHub Desktop.
AppleScript to show current playing iTunes song using Growl notification
-- Register with Growl
tell application "GrowlHelperApp"
-- The notification types
set the allNotificationsList to {"Current Song"}
set the enabledNotificationList to allNotificationsList
-- Register script with growl
register as application ¬
"iTunes Current Song AppleScript" all notifications allNotificationsList ¬
default notifications enabledNotificationList ¬
icon of application "iTunes"
end tell
-- Display the track if iTunes is running
if appIsRunning("iTunes") then
tell application "iTunes"
if exists name of current track then
set aTrack to the current track
set aName to the name of aTrack
set aArtist to the artist of aTrack
-- User artwork as icon if available otherwise default icon (iTunes icon)
if (count of artwork of aTrack) ≥ 1 then
set anArtwork to data of artwork 1 of aTrack
tell application "GrowlHelperApp" to ¬
notify with name "Current Song" title aArtist description aName application name "iTunes Current Song AppleScript" pictImage anArtwork
else
tell application "GrowlHelperApp" to ¬
notify with name "Current Song" title aArtist description aName application name "iTunes Current Song AppleScript"
end if
else
tell application "GrowlHelperApp" to ¬
notify with name "Current Song" title "Current Song" description "No song playing" application name "iTunes Current Song AppleScript"
end if
end tell
else
tell application "GrowlHelperApp" to ¬
notify with name "Current Song" title "iTunes is not running" description "" application name "iTunes Current Song AppleScript"
end if
-- Check if application is running
on appIsRunning(appName)
tell application "System Events" to (name of processes) contains appName
end appIsRunning
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment