guest@dotshare [~/groups/info/dzen2] $ ls performant-music-script/ | cat

performant music script (scrot)

foozer May 14, 2013 (info/dzen2)

baraction.sh(raw, dl)

SCROT

 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
#!/bin/bash

if [ -n "$1" ] && [ $1 == "update" ]; then
        echo $MPD_STATUS_STATE > $HOME/.mpd/bar/state
        echo $MPD_SONG_TAG_ARTIST - $MPD_SONG_TAG_TITLE > $HOME/.mpd/bar/song
        kill -USR1 $(cat $HOME/.mpd/bar/pid)
        exit 0
fi

resume() {
        kill $PID
}
trap resume SIGUSR1

while :; do

        SONG=$(cat $HOME/.mpd/bar/song)

        case $(cat $HOME/.mpd/bar/state) in
                "pause")
                        ICON="/home/rolf/.icons/dzen/pause.xbm"
                        ;;
                "play")
                        ICON="/home/rolf/.icons/dzen/play.xbm"
                        ;;
                *)
                        ICON="/home/rolf/.icons/dzen/stop.xbm"
                        SONG="Nothing is playing."
                        ;;
        esac

        echo "^i("/home/rolf/.icons/dzen/phones.xbm") ^fg(#5597b6)^i($ICON)^fg()  $SONG  "

        sleep 60 &
        PID=$!
        echo $PID > $HOME/.mpd/bar/pid
        wait $PID 2>/dev/null

done | dzen2 -w 500 -h 12 -x 1420 -y 2 -fg "#aaaaaa" -bg "#151515" -fn "-*-profont-*-*-*-*-12-*-*-*-*-*-*-*" -ta r

CLICK TO VIEW

x

hooks_state(raw, dl)

1
2
3
#!/bin/bash

baraction.sh update
 

x

Notes

This is a very light way to have a dzen with mpd status and current song (and more, should you wish).

Requires mpdcron (http://alip.github.io/mpdcron)

Before running this, execute
mkdir ~/.mpd
mkdir ~/.mpd/bar
touch ~/.mpd/bar/{pid,state,song}

Don’t forget to correct the icon URIs in the script.