Skip to content

Commit

Permalink
Observe if display is off
Browse files Browse the repository at this point in the history
  • Loading branch information
Innei committed Sep 4, 2023
1 parent 015147f commit 12b0ade
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions ProcessReporter/Utils/Reporter/Reporter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,22 @@ class Reporter {
private var disposerList = [Disposable]()

private func sleepHandler() {
let distributedNotificationCenter = DistributedNotificationCenter.default()

distributedNotificationCenter.addObserver(
self,
selector: #selector(systemWillSleep),
name: NSNotification.Name("com.apple.screenIsLocked"),
object: nil
)

distributedNotificationCenter.addObserver(
self,
selector: #selector(systemDidWake),
name: NSNotification.Name("com.apple.screenIsUnlocked"),
object: nil
)

NotificationCenter.default.addObserver(self, selector: #selector(systemWillSleep), name: NSWorkspace.willSleepNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(systemDidWake), name: NSWorkspace.didWakeNotification, object: nil)
}
Expand Down

0 comments on commit 12b0ade

Please sign in to comment.