Skip to content

Instantly share code, notes, and snippets.

@FallenMax
Created September 2, 2022 03:13
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 FallenMax/e0a6f7b75fefacf7f133d139192efb3b to your computer and use it in GitHub Desktop.
Save FallenMax/e0a6f7b75fefacf7f133d139192efb3b to your computer and use it in GitHub Desktop.
some spotify applescript, use skhd to control spotify with shortcut
-- activate
tell application "Spotify"
activate
end tell
-- next track
tell application "Spotify"
next track
delay 1
set trackName to name of current track
set artistName to artist of current track
set albumName to album of current track
-- set isStarred to starred of current track
set playCount to played count of current track
display notification albumName with title artistName & " - " & trackName
end tell
-- previous track
tell application "Spotify"
previous track
delay 1
set trackName to name of current track
set artistName to artist of current track
set albumName to album of current track
-- set isStarred to starred of current track
set playCount to played count of current track
display notification albumName with title artistName & " - " & trackName
end tell
-- play/pause
tell application "Spotify"
playpause
delay 1
set trackName to name of current track
set artistName to artist of current track
set albumName to album of current track
-- set isStarred to starred of current track
set playCount to played count of current track
display notification albumName with title artistName & " - " & trackName
end tell
-- show current track
-- https://computers.tutsplus.com/tutorials/the-ultimate-beginners-guide-to-applescript--mac-3436
-- open with Script Editor, check `Dictionary` for available commands
-- reference: https://developer.apple.com/library/archive/documentation/AppleScript/Conceptual/AppleScriptLangGuide/reference/ASLR_cmds.html
tell application "Spotify"
set trackName to name of current track
set artistName to artist of current track
set albumName to album of current track
-- set isStarred to starred of current track
set playCount to played count of current track
display notification albumName with title artistName & " - " & trackName
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment