How can I read the status of the battery on my MacBookPro from my own application?
Googling has so far only revealed APIs for device drivers to handle power events – there’s nothing about user-land processes accessing this information.
thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You’ll want to use IOKit for this, specifically the IOPowerSources functions. You can use
IOPSCopyPowerSourcesInfo()to get a blob, andIOPSCopyPowerSourcesList()to then extract a CFArray out of that, listing the power sources. Then useIOPSGetPowerSourceDescription()to pull out a dictionary (see IOPSKeys.h for the contents of the dictionary).