Don't iterate over all running apps

This commit is contained in:
Ivan Grachyov 2021-06-16 20:53:31 +03:00
parent 87492d90ff
commit eb045017dd

View File

@ -24,9 +24,8 @@ struct Window {
static func activateBrowser() {
// TODO: support more browsers
let apps = NSWorkspace().runningApplications
for bundleId in ["com.apple.Safari", "com.google.Chrome"] {
if let browser = apps.first(where: { $0.bundleIdentifier == bundleId}) {
if let browser = NSRunningApplication.runningApplications(withBundleIdentifier: bundleId).first {
browser.activate(options: .activateIgnoringOtherApps)
return
}