dotfiles/spotify.applescript

21 lines
671 B
AppleScript
Raw Normal View History

2024-02-05 15:06:15 +01:00
#!/usr/bin/env osascript
# Returns the current playing song in Spotify for OSX
tell application "Spotify"
if it is running then
if player state is playing then
set track_name to name of current track
set artist_name to artist of current track
if artist_name > 0
# If the track has an artist set and is therefore most likely a song rather than an advert
2024-02-06 08:44:48 +01:00
" ♫ " & artist_name & " - " & track_name
2024-02-05 15:06:15 +01:00
else
# If the track doesn't have an artist set and is therefore most likely an advert rather than a song
2024-02-06 08:44:48 +01:00
" ~ " & track_name
2024-02-05 15:06:15 +01:00
end if
else
2024-02-06 08:44:48 +01:00
" ⏸︎ Spotify is paused"
2024-02-05 15:06:15 +01:00
end if
end if
end tell