I want to prevent my app doing certain things when the user is watching a movie, running a slideshow or performing any other activity where the machine is in active use but the mouse and keyboard are idle.
I know calling UpdateSystemActivity() every 30 seconds prevents the screensaver from firing, but I’m interested in whether there is any way we can detect that the screensaver is being prevented from running or not.
It must be App Store safe
My notes say that there’s a way to do this using an undocumented class,
ScreenSaverController. Here’s the header:And here’s how to use it:
Note that you will need to link against the
ScreenSaverframework to use this. Since this is an undocumented class, doing so will make your application ineligible for the Mac App Store.Also take a look at
screenSaverTimeRemaining— some methods of preventing the screensaver from starting may just continuously reset this.