source: mpd-status/trunk/examples/status @ 25

Last change on this file since 25 was 25, checked in by simon, 19 years ago

Update README with more general instructions. Add wmii status rc script examples.

  • Property svn:executable set to *
File size: 1.4 KB
RevLine 
[25]1#!/usr/lib/9base/bin/rc
2# periodically print stuff to the bar
3
4PIDFILE=/tmp/.ixp-$USER/statuspid-$WMII_IDENT
5
6if(test -r $PIDFILE) {
7    kill -2 `{cat $PIDFILE} >[2]/dev/null
8}
9echo $pid >$PIDFILE
10
11mpdlab=`{wmiir read /bar/new}
12wmiir write /bar/$mpdlab/b1press 'extern mpc prev'
13wmiir write /bar/$mpdlab/b2press 'extern mpc toggle'
14wmiir write /bar/$mpdlab/b3press 'extern mpc next'
15wmiir write /bar/$mpdlab/b4press 'extern mpc volume -5'
16wmiir write /bar/$mpdlab/b5press 'extern mpc volume +5'
17
18# date and load average
19
20label=`{wmiir read /bar/new}
21wmiir write /bar/$label/b1press 'wmiir write /wm/ctl ''select prev'''
22wmiir write /bar/$label/b3press 'wmiir write /wm/ctl ''select next'''
23wmiir write /bar/$label/b4press 'wmiir write /wm/ctl ''select prev'''
24wmiir write /bar/$label/b5press 'wmiir write /wm/ctl ''select next'''
25
26# install signal handler for artificial sigexit:
27fn sigint {
28    if(test -f $PIDFILE && ~ `{cat $PIDFILE} $pid)
29        rm -f $PIDFILE
30    wmiir write /bar/ctl 'destroy '^$mpdlab
31    wmiir write /bar/ctl 'destroy '^$label
32    exit
33}
34
35fn mpdstatus {
36    echo (`{python2.4 $HOME/.wmii/scripts/mpc.py})
37}
38
39fn statustext {
40    # if you need a formatted date, use awk
41    echo (`{date} `{uptime | sed 's/.*://; s/,//g'})
42}
43
44mpdtext=`{mpdstatus}
45text=`{statustext}
46while(wmiir write /bar/$mpdlab/data $"mpdtext >[2]/dev/null; wmiir write /bar/$label/data $"text >[2]/dev/null) {
47    sleep 2
48    mpdtext=`{mpdstatus}
49    text=`{statustext}
50}
Note: See TracBrowser for help on using the repository browser.