Skip to content

Instantly share code, notes, and snippets.

@brettinternet
Forked from JorenSix/now_playing.osascript
Created February 25, 2017 08:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brettinternet/e513ce313352d8fc45e5ed1dfd2f02c5 to your computer and use it in GitHub Desktop.
Save brettinternet/e513ce313352d8fc45e5ed1dfd2f02c5 to your computer and use it in GitHub Desktop.
This osascript gets and returns the meta data of the track that is currently playing in Spotify on Mac OS X.
#!/usr/bin/osascript
#
# now_playing.osascript
#
# Osascript to fetch the meta data of the currently playing
# track in Spotify. This works only on Mac OS X.
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 "Stopped"
else
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 & " | " & "Playing"
else if player state is paused then
set output to trackname & " | " & artistname & " | " & albumname & " | " & "Paused"
end if
end if
end tell
else
set output to "Spotify not running"
end if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment