feat: keep launcher hidden when started at login

This commit is contained in:
2026-10-12 09:58:43 +02:00
parent ac74a26f3b
commit d4312eb839
2 changed files with 26 additions and 3 deletions
+20 -3
View File
@@ -93,6 +93,13 @@ private final class ApplicationDelegate: NSObject, NSApplicationDelegate {
private lazy var launcher = LauncherWindowController()
private lazy var shortcut = GlobalShortcut { [weak self] in self?.launcher.toggle() }
private lazy var settings = SettingsWindowController(shortcut: shortcut)
private var startupShortcutError: String?
private var isLoginLaunch: Bool {
let event = NSAppleEventManager.shared().currentAppleEvent
return event?.eventID == kAEOpenApplication
&& event?.paramDescriptor(forKeyword: keyAEPropData)?.enumCodeValue == keyAELaunchedAsLogInItem
}
func applicationDidFinishLaunching(_ notification: Notification) {
let menu = NSMenu()
@@ -102,21 +109,31 @@ private final class ApplicationDelegate: NSObject, NSApplicationDelegate {
let quitItem = menu.addItem(withTitle: "Quit Conjure", action: #selector(NSApplication.terminate(_:)), keyEquivalent: "q")
quitItem.target = NSApplication.shared
launcher.window?.contentView?.menu = menu
launcher.present()
if !isLoginLaunch {
launcher.present()
}
do {
try shortcut.start()
} catch {
settings.present(error: error.localizedDescription)
startupShortcutError = error.localizedDescription
if !isLoginLaunch {
showSettings(nil)
}
}
}
func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows: Bool) -> Bool {
guard !isLoginLaunch else { return false }
launcher.present()
if startupShortcutError != nil {
showSettings(nil)
}
return false
}
@objc func showSettings(_ sender: Any?) {
settings.present()
settings.present(error: startupShortcutError)
startupShortcutError = nil
}
func applicationWillTerminate(_ notification: Notification) {