feat: add destination-specific global shortcuts

This commit is contained in:
Valdemar Lorenzen
2026-10-15 15:00:51 +02:00
parent 8946b19b7a
commit 6bb2b4a482
12 changed files with 383 additions and 53 deletions
+12 -10
View File
@@ -92,8 +92,13 @@ struct ConjureApp {
private final class ApplicationDelegate: NSObject, NSApplicationDelegate {
private let uninstaller = ApplicationUninstaller()
private lazy var launcher = LauncherWindowController(uninstaller: uninstaller)
private lazy var shortcut = GlobalShortcut { [weak self] in self?.launcher.toggle() }
private lazy var settings = SettingsWindowController(shortcut: shortcut)
private lazy var shortcuts = GlobalShortcuts { [weak self] destination in
switch destination {
case .launcher: self?.launcher.toggle()
case .command(let command): self?.launcher.toggle(command: command)
}
}
private lazy var settings = SettingsWindowController(shortcuts: shortcuts)
private var startupShortcutError: String?
private var startupRecoveryMessage: String?
@@ -123,13 +128,10 @@ private final class ApplicationDelegate: NSObject, NSApplicationDelegate {
if !isLoginLaunch {
launcher.present()
}
do {
try shortcut.start()
} catch {
startupShortcutError = error.localizedDescription
if !isLoginLaunch {
showSettings(nil)
}
let shortcutErrors = shortcuts.start()
if !shortcutErrors.isEmpty {
startupShortcutError = shortcutErrors.joined(separator: "\n")
if !isLoginLaunch { showSettings(nil) }
}
}
@@ -149,7 +151,7 @@ private final class ApplicationDelegate: NSObject, NSApplicationDelegate {
}
func applicationWillTerminate(_ notification: Notification) {
shortcut.stop()
shortcuts.stop()
}
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {