Skip to content

Instantly share code, notes, and snippets.

@ArtikusHG
Created June 14, 2018 09:29
Show Gist options
  • Save ArtikusHG/d5b905e52fae96346f691c0914ee981b to your computer and use it in GitHub Desktop.
Save ArtikusHG/d5b905e52fae96346f691c0914ee981b to your computer and use it in GitHub Desktop.
#!/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
@JasonMiesionczek
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment