Skip to content

Instantly share code, notes, and snippets.

@ForeverZer0
Created April 9, 2024 04:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ForeverZer0/9b9b3b2775ea931b6b95a2b16e9f1d6a to your computer and use it in GitHub Desktop.
Save ForeverZer0/9b9b3b2775ea931b6b95a2b16e9f1d6a to your computer and use it in GitHub Desktop.
Simple script to display dunst notifications with title, artist, and album art when the current song changes in MPD.
#!/usr/bin/env bash
# Simple script to display display a notification when the current song changes
# in MPD, showing the title, artist, and cover/album art.
#
# Requires: dunst, mpd, and mpc
ALBUMART="/tmp/albumart"
TIMEOUT=3000
song=$(mpc current --format "%file%")
while true
do
current=$(mpc current --format "%file%")
if [ "$song" != "$current" ]; then
song="$current"
mpc albumart "$song" > $ALBUMART
title=$(mpc current --format "%title%")
artist=$(mpc current --format "%artist%")
dunstify -a mpd-notify -u 0 -I "$ALBUMART" -t $TIMEOUT -h "string:x-dunst-stack-tag:mpd-notify" "$title" "$artist"
fi
mpc idle player > /dev/null
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment