diff --git a/DockDoor/AppDelegate.swift b/DockDoor/AppDelegate.swift index a82ef748..200853fb 100644 --- a/DockDoor/AppDelegate.swift +++ b/DockDoor/AppDelegate.swift @@ -37,6 +37,11 @@ class AppDelegate: NSObject, NSApplicationDelegate { } func applicationDidFinishLaunching(_ aNotification: Notification) { + self.setupMenuBar() + if !Defaults[.showMenuBarIcon] { + self.scheduleMenuBarIconVisibilityUpdate() + } + if !Defaults[.launched] { handleFirstTimeLaunch() } else { @@ -48,15 +53,13 @@ class AppDelegate: NSObject, NSApplicationDelegate { } } - func applicationDidBecomeActive(_ notification: Notification) { + func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool { self.setupMenuBar() - - // Schedule a timer to remove the menu bar icon after 10 seconds if it's turned off if !Defaults[.showMenuBarIcon] { - DispatchQueue.main.asyncAfter(deadline: .now() + 10) { - self.updateMenuBarIconStatus() - } + self.scheduleMenuBarIconVisibilityUpdate() } + + return false } private func setupMenuBar() { @@ -88,6 +91,12 @@ class AppDelegate: NSObject, NSApplicationDelegate { } } + private func scheduleMenuBarIconVisibilityUpdate() { + DispatchQueue.main.asyncAfter(deadline: .now() + 10) { + self.updateMenuBarIconStatus() + } + } + @objc func statusBarButtonClicked(_ sender: Any?) { // Show the menu if let button = statusBarItem?.button {