From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14110 invoked by alias); 13 Jul 2010 14:29:59 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 15184 Received: (qmail 1083 invoked from network); 13 Jul 2010 14:29:47 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at benizi.com designates 64.130.10.15 as permitted sender) Date: Tue, 13 Jul 2010 10:29:15 -0400 (EDT) From: "Benjamin R. Haskell" To: Atom Smasher cc: zsh-users@zsh.org Subject: Re: zsh portable script In-Reply-To: <1007140055140.5546@smasher> Message-ID: References: <1007130241570.5546@smasher> <201007121737.21296.joke@seiken.de> <201007121745.20332.joke@seiken.de> <20100712161519.GO1499@prunille.vinc17.org> <1007140055140.5546@smasher> User-Agent: Alpine 2.01 (LNX 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Wed, 14 Jul 2010, Atom Smasher wrote: > as i suspected, there isn't a *good* way to do it. > > instructions at the top of the script suggest putting it in a crontab as: > * * * * * /path/to/zsh /path/to/script > > btw, this is the bat-mon script that, until recently, only worked with > freebsd. now it also works with linux. > > http://smasher.org/zsh/ > > enjoy... I've one-lined perl scripts at various points to grab roughly the same information. My favorite: perl -lnwe 'if($a){print$a/$_}else{$a=$_}' /sys/class/power_supply/BAT0/charge_{now,full} But, I don't recall ever needing root to read the battery status. (In the /proc/acpi subsystem that you're using, /proc/acpi/battery/BAT{0,1}/{info,state} are chmod 0444 on my laptop and netbook; same for the /sys/class/ stuff I used above.) And on my FreeBSD webhost where I have pretty resticted access, I seem to be able to grab a lot of hardware-related info via sysctl. Are permissions the reason you suggest running it under cron? Otherwise, why not just regenerate in precmd()? -- Best, Ben