In Quids, similar to 1Password, we lock the app when your Mac locks.
There are two notifications sent via the DistributedNotificationCenter
. One when the screen is locked and the other when it is unlocked. I couldn't find any predefined variables so created this Notification.Name
extension:
internal extension Notification.Name
{
static let screenIsLocked = Notification.Name("com.apple.screenIsLocked")
static let screenIsUnlocked = Notification.Name("com.apple.screenIsUnlocked")
}
Then all that is left to do is register an object as an observer:
DistributedNotificationCenter.default().addObserver(self, selector: #selector(...), name: Notification.Name.screenIsLocked, object: nil)