Skip to content

Commit

Permalink
Move libkrbn_services_register_core_daemons and libkrbn_services_regi…
Browse files Browse the repository at this point in the history
…ster_core_agents to ServicesMonitor from AppDelegate
  • Loading branch information
tekezo committed Aug 5, 2024
1 parent 558e855 commit 3733d94
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/apps/SettingsWindow/src/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,10 @@ public class AppDelegate: NSObject, NSApplicationDelegate {
NSApp.activate(ignoringOtherApps: true)

//
// Register services
// Unregister old agents
//

libkrbn_services_bootout_old_agents()
libkrbn_services_register_core_daemons()
libkrbn_services_register_core_agents()
}

public func applicationWillTerminate(_: Notification) {
Expand Down
5 changes: 5 additions & 0 deletions src/apps/SettingsWindow/src/ServicesMonitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ public class ServicesMonitor: ObservableObject {
}
}

// If Karabiner-Elements was manually terminated just before, the agents are in an unregistered state.
// So we should enable them once before checking the status.
libkrbn_services_register_core_daemons()
libkrbn_services_register_core_agents()

// When updating Karabiner-Elements, after the new version is installed, the daemons, agents, and Settings will restart.
// To prevent alerts from appearing at that time, if the daemons or agents are enabled, wait for the timer to fire for the process startup check.
// If either the daemons or agents are not enabled, usually when the daemons are not approved, trigger the timer immediately after startup to show the alert right away.
Expand Down

0 comments on commit 3733d94

Please sign in to comment.