Re: [wmii] Status script

From: Georg Neis <gn_AT_oglaroon.de>
Date: Fri, 28 Oct 2005 13:36:45 +0200

Please always state which version you are using.

* Jani H. Lahtinen <jani.h.lahtinen_AT_nokia.com> wrote:
> I tried to modify my status -script to display the time, wireless
> connection quality and the laptop battery status. I copied the Garbeam's
> dotfiles and changes the block of the while loop in the status -script to:
>
> date=`{date '+%H:%M'}
> signal=`{cat /proc/net/wireless | awk '{print $3}' | sed -n '3p'}
> cap=`{cat /proc/acpi/battery/BAT0/info | sed -n 's/last full
> capacity:\s*\([0-9]*\) mWh/\1/p'}
> rem=`{cat /proc/acpi/battery/BAT0/state | sed -n 's/remaining
> capacity:\s*\([0-9]*\) mWh/\1/p'}
> battery=`{dc -e $"rem^' 100 * '$"cap^' / p'}
> text=$"date^' '^$"signal^' '^$"battery
> sleep $DELAY
>
> The wlan quality is displayed fine, but strangely the battery status
> only shows 100 all the time. If I simply start /usr/local/9/bin/rc and
> cut-and-paste the above instruction `echo $text` shows a credible
> reading of the battery state. What's the mystery?

The status script, like all actions, is executed under an environment
where PATH contains 9PREFIX/bin before all the usual bin directories.
This means that sed is the Plan 9 sed, which uses the same regular
expression notation as all the other Plan 9 tools:
http://swtch.com/plan9port/man/man7/regexp.html

If I remember correctly, this is what on Unix is known as extended REs,
in contrast to the basic REs that the Unix sed uses.
Received on Fri Oct 28 2005 - 13:38:16 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:59:24 UTC