Created
June 14, 2018 09:29
-
-
Save ArtikusHG/d5b905e52fae96346f691c0914ee981b to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# Get the song that is currently played and store it to a variable | |
oldsong=$(mpc current) | |
# Stays on loop while the script is active | |
while "true"; do | |
# Check if the current song is equal to the one that was playing before (oldsong) | |
if [[ "$(mpc current)" != "$oldsong" ]]; then | |
# If not equal, assign the new song to the variable to be checking again correctly | |
oldsong=$(mpc current) | |
# And send the notification | |
notify-send "Now playing" "$(mpc current)" | |
fi | |
# Change "1" to any value in seconds you want | |
sleep 1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Inside the while loop I would store the results of mpc current to a variable, so when entering the if block, you don't have to run it again