Skip to content

Instantly share code, notes, and snippets.

@mfilej
Created October 17, 2009 17:46
Show Gist options
  • Save mfilej/212411 to your computer and use it in GitHub Desktop.
Save mfilej/212411 to your computer and use it in GitHub Desktop.
get the current song from iTunes
#! /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