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 Dec 15, '10 02:42:11AM

I just realized I've never thanked you for explaining the commands.
I've (at the time) just started to work with awk and your detailed breakdown helped a lot in understanding.
People like you make this site to what it is!
So, some months late but from my heart ... THANK YOU!


In the meantime I've not only understood what awk does, but could also adapt it to a different ioreg-syntax, thus speeding up the command by a factor of 15 (thats a speed increase of 1500% - well worth a try).

50 iterations of the original command took a 15.3 secs on a MacBook (not Pro) Unibody.
The same number of iterations with the modified line take only 1.1 sec...:

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

Edited on Dec 15, '10 03:09:14AM by mael



[ Reply to This | # ]