How do I get the current power source on a Mac, using IOKit
?
I want to see if the Mac is running via the built-in battery or via a power adapter.
The functions in IOPowerSources.h (specifically, IOPSGetProvidingPowerSourceType()
) will give you the info you're looking for.