#!/bin/sh
# Time-stamp: <2008-08-16 20:21:40 fred>

ICONPATH=${ICONPATH:-'/donnees/images/icons'}

# The following variables should be inherited from the calling
# environment, but set here 'just in case'
BG=${ALTBG:-'#2b4f98'}  # dzen backgrounad
FG=${ALTFG:-'grey'}  # dzen foreground
MOCP_BEGIN=${MOCP_BEGIN:-641}
MOCP_W=${MOCP_W:-300}     # width of the dzen bar
FN=${FN:-'-*-clean-*-*-*-*-*-120-*-*-*-*-iso8859-*'} # font

TIME_INT=2

while true; do
    state=$( mocp --format "%state" )
    
    case $state in
	PLAY)
	    echo -n "^i(${ICONPATH}/mpd.xbm)"
	    mocp --format " %title"
            ;;
        PAUSE)
	    echo -n "^i(${ICONPATH}/mpd.xbm)"
	    mocp --format " (pause) %title"
	    ;;
        STOP)
            echo " ^r(7x7)"
            ;;
    esac
    sleep $TIME_INT
done | dzen2 -ta l -tw $MOCP_W -x $MOCP_BEGIN -fg $FG -bg $BG -fn $FN
