aboutsummaryrefslogtreecommitdiffstats
path: root/.config/herbstluftwm/mpc-status.sh
blob: 221b0a9da2da3cb11a26daf453e4ed230d7b3b57 (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
#!/usr/bin/env zsh

source $HOME/.config/init/vars

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

mpc status >/dev/null 2>&1
if [[ $? -ne 0 ]]; then
	dunstify -h string:x-dunst-stack-tag:mpd "mpd disconnected"
	exit
fi

if [[ -z $(mpc status | grep -E '\[(playing|paused)\]') ]]; then
	dunstify -h string:x-dunst-stack-tag:mpd "mpd stopped"
	exit
fi

dir=${"$(mpc current -f %file%)":h}

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')"

dunstify -t 4000 -h string:x-dunst-stack-tag:mpd --icon="$HOME/music/$dir/cover-small.png" $message