Monitoring Screensaver Events in OSX

后端 未结 3 1535
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-02 16:45

I want to monitor screensaver and lockscreen events on an OSX box. As a first pass, I\'m fine with them just printing to the console.

Following the advice of another\'s

3条回答
  •  情话喂你
    2021-02-02 17:15

    You've commented your problem already.

    while(1); // busy wait's bad, I know, but easy to implement
    

    The above is almost ALWAYS a bad idea.

    NSDistributedNotificationCenter actually requires a running main thread NSRunLoop to operate.

    http://developer.apple.com/library/ios/#documentation/cocoa/Conceptual/Notifications/Articles/NotificationCenters.html#//apple_ref/doc/uid/20000216-BAJGDAFC

    Creating and spinning a run loop from the main() of a command line application on OS X is a fairly simple thing to do. There are plenty of examples available with a quick search.

提交回复
热议问题