Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
"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