Skip to content

Instantly share code, notes, and snippets.

@sarahstreza
Created November 10, 2011 23:07
Show Gist options
  • Select an option

  • Save sarahstreza/1356566 to your computer and use it in GitHub Desktop.

Select an option

Save sarahstreza/1356566 to your computer and use it in GitHub Desktop.
# Save to: ~/Library/Application Support/Textual/Scripts/
# Call with: /spotify
on textualcmd()
set nowPlaying to "I'm not currently playing anything."
# Spotify
if isRunning("Spotify") then
tell application "Spotify"
if player state is playing then set nowPlaying to name of current track & " - " & artist of current track & " on Spotify (" & spotify url of current track & ")"
end tell
end if
# iTunes
if isRunning("iTunes") then
tell application "iTunes"
if player state is playing then set nowPlaying to "iTunes: " & artist of current track & " - " & name of current track & " (" & album of current track & ")"
end tell
end if
# QuickTime Player
if isRunning("QuickTime Player") then
tell application "QuickTime Player"
if playing of document 1 then set nowPlaying to "QuickTime: \"" & name of document 1 & "\""
end tell
end if
return "/me is playing " & nowPlaying
end textualcmd
on isRunning(mediaPlayer)
tell application "System Events"
tell application "System Events" to return exists (processes where name is mediaPlayer)
end tell
end isRunning
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment