Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: zsh portable script

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()?


Messages sorted by: Reverse Date, Date, Thread, Author