Skip to content

Instantly share code, notes, and snippets.

@ahmedsajid
Last active August 27, 2021 19:46
Show Gist options
  • Save ahmedsajid/9c738bb0ac59d905fe41fb7c92e1f937 to your computer and use it in GitHub Desktop.
Save ahmedsajid/9c738bb0ac59d905fe41fb7c92e1f937 to your computer and use it in GitHub Desktop.
Skip Spotify Ads on Linux
# Function to "skip" Spotify Ads by reloading the client
# whenever ad is detected
# Have https://pypi.org/project/spotify-cli-linux/ installed
reload_spotify() {
# Determine what's playing
spotifycli --status | grep -qi 'advertisement\| - Spotify\|^ - '
# If the return matches ads string
if [ $? -eq 0 ]; then
# Kill all instances of Spotify
killall spotify
# Give a little sleep
sleep 0.5
# Start Spotify in background
nohup spotify > /dev/null 2>&1 &
# Play where we left, might be previous song depending
# on at which point Spotify saved its state
spotifycli --play
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment