Skip to content

Commit

Permalink
fix: don't observe com.apple.notificationcenterui
Browse files Browse the repository at this point in the history
  • Loading branch information
rami3l committed Nov 7, 2023
1 parent 10bdf4a commit 5efbe89
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Sources/RunningAppsObserver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,17 @@ class RunningAppsObserver: NSObject {
// https://gist.github.com/ljos/3040846
// https://stackoverflow.com/a/61688877
let includingWindowAppPIDs =
(CGWindowListCopyWindowInfo(.optionAll, kCGNullWindowID)!
as Array)
(CGWindowListCopyWindowInfo(.optionAll, kCGNullWindowID)! as Array)
.compactMap { $0.object(forKey: kCGWindowOwnerPID) as? pid_t }

// HACK: When hiding some system apps, `AXApplicationHidden` is not sent.
// We exclude these apps from the observation for now.
// https://github.com/tekezo/Files/blob/5d783774fec5e45259b9677cdfe09298ff4bd452/app/AXTest/AXTest/Classes/AXApplicationObserverManager.m#L109
let specialSystemAppIDs = ["com.apple.notificationcenterui"] as [String?]

return Set(
workspace.runningApplications.lazy
.filter { !specialSystemAppIDs.contains($0.bundleIdentifier) }
.map { $0.processIdentifier }
.filter { includingWindowAppPIDs.contains($0) }
)
Expand Down

0 comments on commit 5efbe89

Please sign in to comment.