Last active
August 27, 2021 19:46
-
-
Save ahmedsajid/9c738bb0ac59d905fe41fb7c92e1f937 to your computer and use it in GitHub Desktop.
Skip Spotify Ads on Linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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