Skip to content

Instantly share code, notes, and snippets.

@milesrichardson
Created May 17, 2020 01:00
Show Gist options
  • Save milesrichardson/3c998141fe00ae3df83ff3193fe39ab9 to your computer and use it in GitHub Desktop.
Save milesrichardson/3c998141fe00ae3df83ff3193fe39ab9 to your computer and use it in GitHub Desktop.
"Spotify cannot play the current song" - So restart it! (restart spotify from mac command line)
#!/usr/bin/env bash
# I got sick of constantly getting the error from spotify that it cannot play
# the current song. It was really annoying to have to quit, open spotlight,
# Type "spot" and accidentally open spotlight system preferences, wait for spotify
# to open, etc...
# This script, on a mac, uses osascript to quit and relaunch spotify and press play
osascript -e 'tell application "Spotify" to quit'
osascript <<'EOF'
repeat until application "Spotify" is not running
delay 1
end repeat
EOF
open -a Spotify
osascript <<'EOF'
repeat until application "Spotify" is running
delay 1
end repeat
EOF
osascript -e 'tell application "Spotify" to playpause'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment