Search code examples
cobjective-cmacoseventsscreensaver

mac screensaver start event


Is there an event fired when screensaver starts? Like for keychain locking:

OSStatus keychain_locked(SecKeychainEvent keychainEvent, SecKeychainCallbackInfo *info, void *context){...}

Solution

  • Finally found it — the solution is to use NSDistributedNotificationCenter and observe folowing events

    • com.apple.screensaver.didstart
    • com.apple.screensaver.willstop
    • com.apple.screensaver.didstop
    • com.apple.screenIsLocked
    • com.apple.screenIsUnlocked

    Like

    [[NSDistributedNotificationCenter defaultCenter]
       addObserver:self
       selector:@selector(screensaverStarted:)
       name:@"com.apple.screensaver.didstart"
       object:nil];