Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get power usage on a Mac

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 laptops using the MacOS internal power information.

like image 850
Walter Avatar asked Jan 05 '11 10:01

Walter


2 Answers

/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.

like image 76
Annika Backstrom Avatar answered Sep 26 '22 07:09

Annika Backstrom


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.

like image 38
stko Avatar answered Sep 24 '22 07:09

stko