On Dec 1, 2017, at 5:43 PM, Gerriet M. Denkmann <g@...> wrote:
Yes; this is what I did: make a SleepThread (subclass of NSThread) with a CFRunLoop which registers for IORegisterForSystemPower.
Now my app can ask this SleepThread whether it is sleeping or not.
Yes, this seems to be the correct term.
The problem: between NSWorkspaceWillSleepNotification and NSWorkspaceDidWakeNotification this (as any app) will be active from time to time (every few minutes it will be active for almost a minute), which messes up the internals of chronyd.Are you talking about Power Nap mode, where the computer can wake up periodically when it’s asleep to fetch email, etc?
When the computer is active in Power Nap mode (while still sleeping according to my definition above) all apps will run for a short period - not only the ones fetching email etc.
Note that the IORegisterForSystemPower callback doesn't get called for wake/sleep cycles in Power Nap mode. That doesn't make sense to me, but when I filed a bug about it, Apple closed it with "behaves as intended".