How to determine if OSX is on battery and not on power

I would like to configure the functionality of my application when it is in battery mode

How to detect the application in battery mode, etc. when changing mode?

+4
source share
1 answer

IOPSGetTimeRemainingEstimatethe function returns the amount of remaining power.

Quoted from the discussion section:

When connected to an "Unlimited" power supply, for example, from an AC source or any other external source, the return value is kIOPSTimeRemainingUnlimited

"", , , , (, AC Power), - kIOPSTimeRemainingUnknown

, "", , CFTimeInterval , .

, IOPSCopyPowerSourcesInfo > IOPSGetPowerSourceDescription > .


IOPSNotificationCreateRunLoopSource , .

+4

Source: https://habr.com/ru/post/1548329/


All Articles