Created
December 5, 2009 07:27
-
-
Save oskarhagberg/249602 to your computer and use it in GitHub Desktop.
AppleScript to show current playing iTunes song using Growl notification
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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