In macOS, is there a way to be notified when the display (not the whole system) goes to sleep?

226 Views Asked by At

I can register for notifications that the entire system will go to sleep using IORegisterForSystemPower, and this works fine. However, this doesn't seem to report when the display is turned off without the system as a whole going to sleep.

Is there an API (possibly higher level than IOKit, such as AppKit) for being notified of those events? And if not, is there some other notification which coincides with it where I can then poll displays for whether they are asleep using CGDisplayIsAsleep()? (The callback registered with CGDisplayRegisterReconfigurationCallback is not called when the display goes to sleep.)

1

There are 1 best solutions below

0
Coder-256 On