From 2b1fcc75c821d44a4e12d83c816c22deeb143c03 Mon Sep 17 00:00:00 2001 From: Ian Ynda-Hummel Date: Fri, 29 Oct 2021 20:45:30 -0400 Subject: [PATCH] Add some common macOS agents to ignored list Avoiding the bundle check when possible improves performance. --- .../NSRunningApplication+Manageable.swift | 34 +++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/Amethyst/Categories/NSRunningApplication+Manageable.swift b/Amethyst/Categories/NSRunningApplication+Manageable.swift index 52393b6f..7cb9fbf6 100644 --- a/Amethyst/Categories/NSRunningApplication+Manageable.swift +++ b/Amethyst/Categories/NSRunningApplication+Manageable.swift @@ -9,6 +9,27 @@ import AppKit import Foundation +private let ignoredBundleIDs = Set([ + "com.apple.dashboard", + "com.apple.loginwindow", + "com.apple.notificationcenterui", + "com.apple.wifi.WiFiAgent", + "com.apple.Spotlight", + "com.apple.systemuiserver", + "com.apple.dock", + "com.apple.AirPlayUIAgent", + "com.apple.dock.extra", + "com.apple.PowerChime", + "com.apple.WebKit.Networking", + "com.apple.WebKit.WebContent", + "com.apple.WebKit.GPU", + "com.apple.FollowUpUI", + "com.apple.controlcenter", + "com.apple.SoftwareUpdateNotificationManager", + "com.apple.TextInputMenuAgent", + "com.apple.TextInputSwitcher" +]) + protocol BundleIdentifiable { var bundleIdentifier: String? { get } } @@ -17,7 +38,7 @@ extension NSRunningApplication: BundleIdentifiable {} extension NSRunningApplication { var isManageable: Bool { - guard let bundleIdentifier = bundleIdentifier, !isAgent() else { + guard let bundleIdentifier = bundleIdentifier else { return false } @@ -25,13 +46,14 @@ extension NSRunningApplication { return false } - switch bundleIdentifier { - case "com.apple.dashboard": + if ignoredBundleIDs.contains(bundleIdentifier) { return false - case "com.apple.loginwindow": + } + + if isAgent() { return false - default: - return true } + + return true } }