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


Click here to return to the 'Battery levels w/pmset -g pslog' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Battery levels w/pmset -g pslog
Authored by: victory on May 10, '08 03:30:29AM
[Seeing as the original hint was posted several years ago, I'll leave this mini-hint here largely for posterity]

The pmset utility in OSX 10.5 now includes a new feature to loop through a continuous series of battery level updates w/o having to use a separate sleep command:

pmset -g pslog

Which will display battery stats and loop every minute or so.

If you need to monitor battery life (say for troubleshooting) and you don't want to watch the batt. level indicator constantly, here's a quick way to have OSX's text-to-speech tell you the current value every 2 minutes:

ruby -e 'loop do;if %x(pmset -g batt)=~/(\d+%)/;%x(say "battery at #{$1}");end;sleep 120;end'

(This works with the Leopard version of pmset. I haven't tested it w/any other. Why use Ruby instead of a shell script w/pipes to awk/sed/etc? I dunno -- why not? Ruby is awesome :-)

[ Reply to This | # ]