#!/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 # current track playing in mpd # Implement many of mpc's actions in a menu wmiir create /menu/items/mpc/prev 'prev' wmiir create /menu/items/mpc/play 'play' wmiir create /menu/items/mpc/pause 'pause' wmiir create /menu/items/mpc/stop 'stop' wmiir create /menu/items/mpc/next 'next' wmiir create /menu/items/mpc/toggle 'toggle' wmiir create /menu/items/mpc/start 'seek 00:00:00' wmiir create /menu/items/mpc/back 'seek -00:00:05' wmiir create /menu/items/mpc/fwd 'seek +00:00:05' wmiir create /menu/items/mpc/clear 'clear' wmiir create /menu/items/mpc/shuffle 'shuffle' wmiir create /menu/items/mpc/load 'load wmii' wmiir create /menu/items/mpc/save 'save wmii' wmiir create /menu/items/mpc/voldn 'volume -10' wmiir create /menu/items/mpc/volup 'volume +10' wmiir create /menu/items/mpc/repeat 'repeat' wmiir create /menu/items/mpc/random 'random' wmiir create /menu/items/mpc/update 'update' mpdlab=`{wmiir read /bar/new} # Colour between selected and normal wmiir write /bar/$mpdlab/fgcolor '#d4d4d4' wmiir write /bar/$mpdlab/bgcolor '#293139' wmiir write /bar/$mpdlab/bordercolor '#303840' wmiir write /bar/$mpdlab/b1press 'extern mpc toggle' wmiir write /bar/$mpdlab/b2press 'wmiir write /menu/precmd ''extern mpc''; wmiir write /menu/lookup /items/mpc; wmiir write /menu/ctl ''display 1''' wmiir write /bar/$mpdlab/b3press 'extern mpc next' # When changing the volume, display it # (Involves calling bash because I don't really know how to do 9rc) wmiir create /bar/$mpdlab/x-delay 0 wmiir write /bar/$mpdlab/b4press 'wmiir write /bar/'^$mpdlab^'/x-delay 1; extern bash -c ''wmiir write /bar/'^$mpdlab^'/data "$(mpc volume -5 | grep ^volume:)"''' wmiir write /bar/$mpdlab/b5press 'wmiir write /bar/'^$mpdlab^'/x-delay 1; extern bash -c ''wmiir write /bar/'^$mpdlab^'/data "$(mpc volume +5 | grep ^volume:)"''' # 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 '^$mdlab wmiir write /bar/ctl 'destroy '^$label exit } fn mpdstatus { echo (`{$HOME/.wmii/scripts/mpd-status.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/$label/data $"text >[2]/dev/null) { sleep 2 text=`{statustext} # If we've been told to delay, don't update this time round delay=`{wmiir read /bar/$mpdlab/x-delay} if(~ $delay 1) wmiir write /bar/$mpdlab/x-delay 0 if not { mpdtext=`{mpdstatus} wmiir write /bar/$mpdlab/data $"mpdtext >[2]/dev/null } }