From 7b21727285e50b0b050c4ddd70d07542229c5366 Mon Sep 17 00:00:00 2001 From: pants Date: Mon, 21 Sep 2026 14:17:03 -0700 Subject: init --- bin/mpd-monitor | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 bin/mpd-monitor (limited to 'bin/mpd-monitor') diff --git a/bin/mpd-monitor b/bin/mpd-monitor new file mode 100755 index 0000000..009c984 --- /dev/null +++ b/bin/mpd-monitor @@ -0,0 +1,30 @@ +#!/bin/sh + +PID=$(pgrep -x mpc) +if [ -n "$PID" ]; then + echo "another instance of mpd-monitor already running" + exit +fi + +ID=$(mpc current -f %id% ) +mpc idleloop | + while read -r event; do + # if a player event is not output, skip rest of loop + [ "$event" = "player" ] || continue + + # get current id to compare to init id + NEW_ID=$(mpc current -f %id%) + # if a player event 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" "or no metadata for track" -i : + else + notify-send "$TITLE" "$ARTIST" -i : + fi + done -- cgit v1.2.3