only send when track changes
This commit is contained in:
@ -1,10 +1,23 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
ID=$(mpc current -f %id% )
|
||||||
mpc idleloop |
|
mpc idleloop |
|
||||||
while read event; do
|
while read -r event; do
|
||||||
if [[ $event == "player" ]]; then
|
# if a player event is not output, skip rest of loop
|
||||||
dunstctl close-all
|
[ "$event" = "player" ] || continue
|
||||||
TITLE=$(mpc status -f %title% | awk 'NR==1')
|
|
||||||
ARTIST=$(mpc status -f %artist% | awk 'NR==1')
|
# get current id to compare to init id
|
||||||
|
NEW_ID=$(mpc current -f %id%)
|
||||||
|
# if a player even is output, but the track has not changed, skip rest of loop
|
||||||
|
[ "$NEW_ID" != "$ID" ] || continue
|
||||||
|
ID=$NEW_ID
|
||||||
|
|
||||||
|
dunstctl close-all
|
||||||
|
TITLE=$(mpc current -f %title%)
|
||||||
|
ARTIST=$(mpc current -f %artist%)
|
||||||
|
|
||||||
|
if [ -z $TITLE ]; then
|
||||||
|
notify-send "End of queue or queue empty" -i :
|
||||||
|
else
|
||||||
notify-send "$TITLE" "$ARTIST" -i :
|
notify-send "$TITLE" "$ARTIST" -i :
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user