[Ti] PB Batteries
Dr. Trevor J. Hutley
hutley at geneva-link.ch
Fri Feb 11 00:01:46 PST 2005
At 15:27 -0500 7/2/05, John Griffin wrote:
>Hmm! All I get is a series of error codes!
John - well, the script worked for me, in that it gave me the
following output in Terminal:
capacity=4032 amperage=0 current=3840 voltage=12365
These values presumably reflect my current 95% state of charge, and
that of being plugged in.
When I unplug, the values are:
capacity=4032 amperage=1469 current=3794 voltage=11614
This is the ACTUAL script (between the lines) that I just pasted in
to Terminal, so I know it works:
_________________________________________________________
#
#!/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
#
______________________________________________________________
regards, Trevor
More information about the Titanium
mailing list