How to get power usage on a Mac

前端 未结 3 1679
南方客
南方客 2021-02-14 18:36

I\'m trying to get the power usage (in watts) but I can\'t figure out how. I looked at pmset and IOKit but couldn\'t find anything about it. coconutBattery can calculate it for

相关标签:
3条回答
  • 2021-02-14 19:35
    /usr/sbin/system_profiler SPPowerDataType | grep Wattage
    

    The utility also accepts an -xml flag; the specific key in the XML is sppower_ac_charger_watts.

    0 讨论(0)
  • 2021-02-14 19:40

    If you only need this information for a laptop, call IOPMCopyBatteryInfo and look at the values for the kIOBatteryVoltageKey and kIOBatteryAmperageKey keys to compute the power usage.

    0 讨论(0)
  • 2021-02-14 19:40

    You should use ioreg -n "AppleSmartBatteryManager" -r -l and from there it should be easy to calculate.

    0 讨论(0)
提交回复
热议问题