mac screensaver start event

前端 未结 3 1172
感动是毒
感动是毒 2020-12-24 00:29

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

OSStatus keychain_locked(SecKeychainEvent keychainEvent, SecKeychainCallbackInfo          


        
3条回答
  •  再見小時候
    2020-12-24 01:06

    This isn't exactly an answer to the question, but I spent a lot of time looking in vain for a list of the notifications posted by macOS, so I wanted to post some code I wrote for notification discovery.

    The code simply signs up to listen to all notifications, and prints some info for each as it comes in.

    import Foundation
    
    let distCenter = CFNotificationCenterGetDistributedCenter()
    if distCenter == nil {
        exit(1)
    }
    
    CFNotificationCenterAddObserver(distCenter, nil, { (center, observer, name, object, userInfo) -> Void in
            print("Event occurred: \(name)  User info: \(userInfo)")
        }, nil, nil, .DeliverImmediately)
    
    CFRunLoopRun()
    

提交回复
热议问题