Created
October 17, 2009 17:46
-
-
Save mfilej/212411 to your computer and use it in GitHub Desktop.
get the current song from iTunes
This file contains hidden or 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
#! /bin/sh | |
# mostly from http://www.macosxhints.com/article.php?story=2004070301135736 | |
# using with GeekTool | |
if ps x \ | |
| grep [/]Applications/iTunes.app/Contents/MacOS/iTunes \ | |
> /dev/null; then | |
osascript - <<'OSASCRIPT' | |
tell application "iTunes" | |
if not (exists current track) then return | |
set sup to (get player state as string) | |
if not (sup = "playing") then return | |
set intro to "Now playing " | |
set sep to " by " | |
set song to current track | |
set result to intro & name of song as text & sep & artist of song | |
end tell | |
OSASCRIPT | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment