Skip to content

Commit d404f4f

Browse files
committed
Use newer APIs to launch applications to fix issue gbammc#38
1 parent 8b18fe6 commit d404f4f

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Thor/ShortcutMonitor.swift

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//
88

99
import Foundation
10+
import Cocoa
1011
import MASShortcut
1112

1213
struct ShortcutMonitor {
@@ -22,7 +23,18 @@ struct ShortcutMonitor {
2223
frontmostAppIdentifier == targetAppIdentifier {
2324
NSRunningApplication.runningApplications(withBundleIdentifier: frontmostAppIdentifier).first?.hide()
2425
} else {
25-
NSWorkspace.shared.launchApplication(app.appName)
26+
if #available(macOS 10.15, *) {
27+
let configuration = NSWorkspace.OpenConfiguration()
28+
configuration.activates = true
29+
NSWorkspace.shared.openApplication(at: app.appBundleURL,
30+
configuration: configuration) { _, error in
31+
if let error = error {
32+
NSLog("ERROR: \(error)")
33+
}
34+
}
35+
} else {
36+
NSWorkspace.shared.launchApplication(app.appName)
37+
}
2638
}
2739
})
2840
}

0 commit comments

Comments
 (0)