aboutsummaryrefslogtreecommitdiffstats
path: root/.config/herbstluftwm/mpc-status.sh
blob: 1c44eeec5d48f165a79da3e1b85ca7eb52899cea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash

case "$1" in
	next)
		mpc next
		;;
	prev)
		mpc prev
		;;
	*)
		;;
esac

mpc status >/dev/null 2>&1
if [[ $? -ne 0 ]]; then
	killall -SIGUSR1 dunst
	notify-send "mpd disconnected"
	exit
fi

if [[ -z "$(mpc status | grep -E '\[(playing|paused)\]')" ]]; then
	killall -SIGUSR1 dunst
	notify-send "mpd stopped"
	exit
fi

cd ~/music/
dir=$(dirname "$(mpc current -f %file%)")
# linking is necessary because notify-send can't into icon paths containing commas
cd /tmp/
ln -sf "$HOME/music/$dir/cover-small.png" mpd-icon.png

message="$(mpc current -f '##%track% %title% (%date%)\n%artist% - %album%')

$(mpc status | tail -n -2 | sed -re 's/volume.*repeat/\nrepeat/' -e 's/( ){3,4}/\n/g' -e '/volume:  /d')"

# i patched dunst to clear all on SIGUSR1
killall -SIGUSR1 dunst

notify-send --icon=/tmp/mpd-icon.png "$message"