Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Your battery percentage is going to be:

    100 / DesignCapacity * MaxCapacity
Or, in the way that makes way more sense to me:

    MaxCapacity / DesignCapacity * 100
Which, with your results, yields something to the effect of:

    98.68%
It's kind of (read: very) dirty looking, but you can get the same result with:

    echo $(ioreg -l -n AppleSmartBattery -r | grep MaxCapacity | awk '{print $3}') / $(ioreg -l -n AppleSmartBattery -r | grep DesignCapacity | awk '{print $3}') \* 100 | bc -l


    ioreg -l -n AppleSmartBattery -r | awk '/MaxCapacity/{mc=$3};/DesignCapacity/{dc=$3};END{print 100*mc/dc}'


mine is at 103.211




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: