[Ti] PB Batteries

Arjan Bos arjan.bos at hetnet.nl
Mon Feb 7 12:21:03 PST 2005


Got this from MacOSX hints some years back. It uses the same 
IORegistry, but formats the output into something more readable:
Put this in a file, make it executable  with the terminal and execute 
it via the terminal.
#-- snip here
#!/bin/bash

[ -x /usr/sbin/ioreg ] && \
     /usr/sbin/ioreg -p IODeviceTree -n "battery" -w 0 | \
     sed -ne '/| *{/,/| *}/ {
	s/^[ |]*//g
	/^[{}]/!p
        }' | \
	   awk '/Battery/ {
                gsub("[{}()\"]","", $3)
                gsub(","," ",$3)
                split($3,ct," ")
                # extract flag value and convert to hex
                sub("Flags=","",ct[2])
                str=sprintf("Flags=%d/0x%03x",ct[2],ct[2])
                sub("Flags=[0-9]*",str,$3)
                # get max and current charge levels
                sub(".*=","",ct[4])
                sub(".*=","",ct[5])
                printf("%s [%.1f%%]\n", tolower($3), 100*ct[5]/ct[4])
                }'

#EOF
# -- and here

Groeten,
Arjan

On 5 feb 2005, at 7:42, heindebruijne wrote:

> Did you know there is a free software program called 'Xbattery'
> that shows you the capacity, level, voltage and current,
> as well as a small little window with short but essential info on your 
> battery?
>
> The nice thing about this little program is:
> you can have and keep it opened on your dektop whenever you like!
>
> Regards from Holland.
> Hein de Bruijne
>
>
>
> Hein de Bruijne
> Langegracht 26
> 3601 AJ  MAARSSEN,  The NETHERLANDS
> Tel.:   +31 346 575 802
> GSM : +31 6 22 99 60 88
>
> _______________________________________________
> Titanium mailing list
> Titanium at listserver.themacintoshguy.com
> http://listserver.themacintoshguy.com/mailman/listinfo/titanium
>
>
---
Multiple exclamation marks are a sure sign of a sick mind

-- (Terry Pratchett, Mort)



More information about the Titanium mailing list