#!/usr/lib/9base/bin/rc # periodically print stuff to the bar PIDFILE=/tmp/.ixp-$USER/statuspid-$WMII_IDENT if(test -r $PIDFILE) { kill -2 `{cat $PIDFILE} >[2]/dev/null } echo $pid >$PIDFILE mpdlab=`{wmiir read /bar/new} wmiir write /bar/$mpdlab/b1press 'extern mpc prev' wmiir write /bar/$mpdlab/b2press 'extern mpc toggle' wmiir write /bar/$mpdlab/b3press 'extern mpc next' wmiir write /bar/$mpdlab/b4press 'extern mpc volume -5' wmiir write /bar/$mpdlab/b5press 'extern mpc volume +5' # date and load average label=`{wmiir read /bar/new} wmiir write /bar/$label/b1press 'wmiir write /wm/ctl ''select prev''' wmiir write /bar/$label/b3press 'wmiir write /wm/ctl ''select next''' wmiir write /bar/$label/b4press 'wmiir write /wm/ctl ''select prev''' wmiir write /bar/$label/b5press 'wmiir write /wm/ctl ''select next''' # install signal handler for artificial sigexit: fn sigint { if(test -f $PIDFILE && ~ `{cat $PIDFILE} $pid) rm -f $PIDFILE wmiir write /bar/ctl 'destroy '^$mpdlab wmiir write /bar/ctl 'destroy '^$label exit } fn mpdstatus { echo (`{python2.4 $HOME/.wmii/scripts/mpc.py}) } fn statustext { # if you need a formatted date, use awk echo (`{date} `{uptime | sed 's/.*://; s/,//g'}) } mpdtext=`{mpdstatus} text=`{statustext} while(wmiir write /bar/$mpdlab/data $"mpdtext >[2]/dev/null; wmiir write /bar/$label/data $"text >[2]/dev/null) { sleep 2 mpdtext=`{mpdstatus} text=`{statustext} }