Re: sleep wake without runloop
If a process is doing anything, it’s awake. Asking “is my process asleep?” is kind of like asking a person “are you asleep?” :)
There is IORegisterForSystemPower which sends seep/wake notifications but needs a runloop.
You can start a background thread and run a runloop on it.
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?