Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'See battery percentage in Terminal and GeekTool' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
See battery percentage in Terminal and GeekTool
Authored by: mael on Feb 05, '10 10:57:02AM
This works for me in 10.6 and 10.5:
pmset -g ps  |  sed -n 's/.*[[:blank:]]+*\(.*%\).*/\1/p'


[ Reply to This | # ]
See battery percentage in Terminal and GeekTool
Authored by: mael on Dec 15, '10 03:12:40AM

Unfortunately pmset spams my system.log with useless messages like
"executing /usr/bin/pmset"

The following command is quicker, more precise, does not make any entries in any log and works for me. It does look a little more complex, though:

ioreg -n AppleSmartBattery -r | awk '$1~/Capacity/{c[$1]=$3} END{OFMT="%.2f%%"; max=c["\"MaxCapacity\""]; print (max>0? 100*c["\"CurrentCapacity\""]/max: "?")}'



[ Reply to This | # ]