As far as I know, a survey is your only option. As user1118321 points out, polling each O (minutes) is unlikely to cause any problems, performance, or otherwise.
If your application has a graphical interface and still accepts user interface events, you can set the handler via +[NSEvent addLocalMonitorForEventsMatchingMask:handler:] , which resets your timer on each event. This will help reduce, if not eliminate, the polls when the user is constantly active, at least in their application.
Once you have determined that the user has been idle for a long time, you can set a global response to the event to view the next event. See For example -[NSEvent addGlobalMonitorForEventsMatchingMask:handler:] .
Note: you should use CGEventSourceSecondsSinceLastEventType , if at all possible, and not squeeze into the IO registry. This is a formal, supported API and may be more efficient. Not to mention this easier. There is also UKIdleTimer , although it relies on Carbon, so it may not apply.
source share