Skip to content

Instantly share code, notes, and snippets.

@jameslittle230
Created November 29, 2017 19:49
Show Gist options
  • Save jameslittle230/dc52c008d77b5ea39742fea74231308e to your computer and use it in GitHub Desktop.
Save jameslittle230/dc52c008d77b5ea39742fea74231308e to your computer and use it in GitHub Desktop.
if application "Spotify" is running and application "iTunes" is not running then
tell application "Spotify"
if player state is stopped then
set display to ""
else
set track_artist to artist of current track
set track_name to name of current track
set track_duration to duration of current track
set seconds_played to player position
set state to ""
if player state is paused then
set state to "(Paused) "
end if
set display to state & track_artist & " - " & track_name
end if
end tell
else if application "Spotify" is running and application "iTunes" is running then
--Get current states of iTunes and Spotify
tell application "iTunes" to set itunesState to (player state as text)
tell application "Spotify" to set spotifyState to (player state as text)
if (itunesState is "paused" or itunesState is "stopped") and spotifyState is "playing" then
tell application "Spotify"
if player state is stopped then
set display to "No Track Playing"
else
set track_artist to artist of current track
set track_name to name of current track
set track_duration to duration of current track
set seconds_played to player position
set state to ""
if player state is paused then
set state to "(Paused) "
end if
set display to state & track_artist & " - " & track_name
end if
end tell
else if itunesState is "playing" and (spotifyState is "paused" or spotifyState is "stopped") then
tell application "iTunes"
if player state is stopped then
set display to "No Track Playing"
else
set track_artist to artist of current track
set track_name to name of current track
set track_duration to duration of current track
set seconds_played to player position
set state to ""
if player state is paused then
set state to "(Paused) "
end if
set display to state & track_artist & " - " & track_name
end if
end tell
else if (itunesState is "paused" or itunesState is "stopped") and spotifyState is "paused" then
set display to "No Track Playing"
else
set display to "Crazyman!!!!"
end if
else if application "iTunes" is running and application "Spotify" is not running then
tell application "iTunes"
if player state is stopped then
set display to "No Track Playing"
else
set track_artist to artist of current track
set track_name to name of current track
set track_duration to duration of current track
set seconds_played to player position
set state to ""
if player state is paused then
set state to "(Paused) "
end if
set display to track_artist & " - " & track_name
end if
end tell
else
set display to ""
end if
if length of display is less than 30 then
set output to display
else
set output to ((text 1 thru 30 of display) & "...")
end if
return output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment