I developed a Menu Extra (menulet) for the Mac but I’d like to know if the machine using the Menu Extra has gone to sleep. I implemented a snooze function but since it’s a time-based method it’s rather unreliable. Any hints or advice would be greatly appreciated!
Thanks!
You probably want to check out
NSWorkspaceWillSleepNotificationin NSWorkspace.The trick is, you need to register for the notifications on NSWorkspace’s notificationCenter, not the default one. See Technical Q&A QA1340.
Sample code: