Display “Now Playing” info on your Desktop with GeekTool

I listen to Seattle’s KEXP streaming radio fairly regularly and even when I’m not I like to know what they’re playing. I use GeekTool to display KEXP’s “Now Playing” song on my Mac Desktop.

curl -silent 'http://kexp.org/playlist/miniplaylist' | perl -l -0777 -ne 'print $1 if /<title.*?>\s*(.*?)\s*<\/title/si' | perl -MHTML::Entities -le 'while(<>) {print decode_entities($_);}'

For Spotify, I have this script:

DATA=$(osascript -e 'tell application "System Events"
set myList to (name of every process)
end tell
if myList contains "Spotify" then
tell application "Spotify"
if player state is stopped then
set output to ""
set trackname to name of current track
set artistname to artist of current track
set albumname to album of current track
if player state is playing then
set output to trackname & " | " & artistname & " | " & albumname
else if player state is paused then
set output to ""
end if
end if
end tell
set output to ""
end if')
echo $DATA | awk -F new_line '{print $1}'
echo $DATA | awk -F new_line '{print $2}'

There are a few places within the code where you can customize what appears if Spotify is paused or stopped. I have those set to be empty. (“”)


Leave a Reply

Your email address will not be published. Required fields are marked *