perf: do login item and plist updates later to accelerate launch
This commit is contained in:
1 parent
a62949f0dc
commit
2f72c5d6ae
2 files changed
+6
-3
No files matched your search
@@ -313,6 +313,8 @@ extension App: NSApplicationDelegate {
|
|||||||
MouseEvents.observe()
|
MouseEvents.observe()
|
||||||
TrackpadEvents.observe()
|
TrackpadEvents.observe()
|
||||||
CliEvents.observe()
|
CliEvents.observe()
|
||||||
|
// login item and plist updates can be done a bit later, to accelerate launch
|
||||||
|
DispatchQueue.main.asyncAfter(deadline: .now() + 2) { GeneralTab.startAtLoginCallback() }
|
||||||
Logger.info("AltTab finished launching")
|
Logger.info("AltTab finished launching")
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
// self.showPreferencesWindow()
|
// self.showPreferencesWindow()
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ class GeneralTab {
|
|||||||
]
|
]
|
||||||
static var menubarIconDropdown: NSPopUpButton?
|
static var menubarIconDropdown: NSPopUpButton?
|
||||||
private static var menubarIsVisibleObserver: NSKeyValueObservation?
|
private static var menubarIsVisibleObserver: NSKeyValueObservation?
|
||||||
|
private static var startAtLoginToggle: NSControl?
|
||||||
|
|
||||||
static func initTab() -> NSView {
|
static func initTab() -> NSView {
|
||||||
let startAtLogin = TableGroupView.Row(leftTitle: NSLocalizedString("Start at login", comment: ""),
|
let startAtLogin = TableGroupView.Row(leftTitle: NSLocalizedString("Start at login", comment: ""),
|
||||||
@@ -44,7 +45,7 @@ class GeneralTab {
|
|||||||
cell.bezelStyle = .regularSquare
|
cell.bezelStyle = .regularSquare
|
||||||
cell.arrowPosition = .arrowAtBottom
|
cell.arrowPosition = .arrowAtBottom
|
||||||
cell.imagePosition = .imageOverlaps
|
cell.imagePosition = .imageOverlaps
|
||||||
startAtLoginCallback(startAtLogin.rightViews[0] as! NSControl)
|
startAtLoginToggle = startAtLogin.rightViews[0] as? NSControl
|
||||||
Menubar.menubarIconCallback(nil)
|
Menubar.menubarIconCallback(nil)
|
||||||
enableDraggingOffMenubarIcon(menuIconShownToggle)
|
enableDraggingOffMenubarIcon(menuIconShownToggle)
|
||||||
let table = TableGroupView(width: PreferencesWindow.width)
|
let table = TableGroupView(width: PreferencesWindow.width)
|
||||||
@@ -83,8 +84,8 @@ class GeneralTab {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// add/remove plist file in ~/Library/LaunchAgents/ depending on the checkbox state
|
/// add/remove plist file in ~/Library/LaunchAgents/ depending on the checkbox state
|
||||||
static func startAtLoginCallback(_ sender: NSControl) {
|
static func startAtLoginCallback(_: NSControl? = nil) {
|
||||||
let sender = sender as! Switch
|
let sender = startAtLoginToggle as! Switch
|
||||||
// if the user has added AltTab manually as a LoginItem, we remove it, and add AltTab as a LaunchAgent
|
// if the user has added AltTab manually as a LoginItem, we remove it, and add AltTab as a LaunchAgent
|
||||||
// LaunchAgent are the recommended method for open-at-login in recent versions of macos
|
// LaunchAgent are the recommended method for open-at-login in recent versions of macos
|
||||||
if (GeneralTab.self as AvoidDeprecationWarnings.Type).removeLoginItemIfPresent() && sender.state == .off {
|
if (GeneralTab.self as AvoidDeprecationWarnings.Type).removeLoginItemIfPresent() && sender.state == .off {
|
||||||
|
|||||||
Reference in new issue
Block a user