Index: /mpd-status/trunk/README
===================================================================
--- /mpd-status/trunk/README	(revision 24)
+++ /mpd-status/trunk/README	(revision 25)
@@ -5,6 +5,7 @@
    [2]wmii's status bar.
 
-   If you want a more featureful status bar, check out [3]szs3rd, from
-   which I shamelessly copied and hacked the mpc.py module.
+   If you want a more featureful status bar for wmii, check out
+   [3]szs3rd, from which I shamelessly copied and hacked the mpc.py
+   module.
 
 Features
@@ -30,21 +31,19 @@
  [7]http://svn.bleah.co.uk/repos/misc/mpd-status/trunk/mpd-status.py
 
-Installation and Usage
+Usage
 
-   (Instructions are based around the setup for wmii 2 in [8]Debian)
+   When run, the script simply outputs current track information (or
+   '--Not playing--') to standard output.  To have this update
+   continuously, run it repeatedly inside a loop construct, for
+   example (using sh):
 
-    1. Place mpd-status.py somewhere, like /usr/local/bin/ or
-       ~/.wmii/scripts/
-    2. Copy /etc/wmii/status.sh to ~/.wmii/status.sh and edit it, or
-       edit /etc/wmii/status.sh directly.
-    3. Edit the following line to include "`python2.4
-       /path/to/mpc.py`" (see patch below for an example):
+ while true
+ do
+     mpd-status.py
+     sleep 1
+ done
 
- text="`date` `uptime | sed -e 's/.*://' -e 's/,//g'`"
-
-    4. Restart wmii: /etc/wmii/rc restart
-
-   You should see some extra text on your wmibar, either "--Not
-   playing--" or your currently playing/paused track.
+   Some example 'status' rc scripts for wmii 2.5 are contained in the
+   examples directory.
 
 License
@@ -76,9 +75,8 @@
   6. http://subversion.tigris.org/
   7. http://svn.bleah.co.uk/repos/misc/mpd-status/trunk/mpd-status.py
-  8. http://www.debian.org/
-  9. http://www.fsf.org/licensing/licenses/gpl.html
-  10. http://www.fsf.org/
-  11. http://www.fsf.org/licensing/licenses/gpl.html
-  12. http://projects.bleah.co.uk/misc/attachment/wiki/MpdStatus/wmii-mpd-status.patch
-  13. http://projects.bleah.co.uk/misc/attachment/wiki/MpdStatus/mpd-status.png
+  8. http://www.fsf.org/licensing/licenses/gpl.html
+  9. http://www.fsf.org/
+  10. http://www.fsf.org/licensing/licenses/gpl.html
+  11. http://projects.bleah.co.uk/misc/attachment/wiki/MpdStatus/wmii-mpd-status.patch
+  12. http://projects.bleah.co.uk/misc/attachment/wiki/MpdStatus/mpd-status.png
 
Index: /mpd-status/trunk/examples/status
===================================================================
--- /mpd-status/trunk/examples/status	(revision 25)
+++ /mpd-status/trunk/examples/status	(revision 25)
@@ -0,0 +1,50 @@
+#!/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}
+}
Index: /mpd-status/trunk/examples/status-actions-menu
===================================================================
--- /mpd-status/trunk/examples/status-actions-menu	(revision 25)
+++ /mpd-status/trunk/examples/status-actions-menu	(revision 25)
@@ -0,0 +1,86 @@
+#!/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
+    }
+}
