Completion

This commit is contained in:
Max Goedjen 2020-11-12 21:17:07 -08:00
parent f2092e597a
commit a3ed59a78c
No known key found for this signature in database
GPG Key ID: E58C21DD77B9B8E8
2 changed files with 5 additions and 3 deletions

View File

@ -40,8 +40,9 @@ struct Secretive: App {
if hasRunSetup && !agentStatusChecker.running {
// We've run setup, we didn't just update, launchd is just not doing it's thing.
// Force a launch directly.
LaunchAgentController().forceLaunch()
agentStatusChecker.check()
LaunchAgentController().forceLaunch { _ in
agentStatusChecker.check()
}
}
}
}

View File

@ -11,10 +11,11 @@ struct LaunchAgentController {
return setEnabled(true)
}
func forceLaunch() {
func forceLaunch(completion: ((Bool) -> Void)?) {
Logger().debug("Agent is not running, attempting to force launch")
let url = Bundle.main.bundleURL.appendingPathComponent("Contents/Library/LoginItems/SecretAgent.app")
NSWorkspace.shared.openApplication(at: url, configuration: NSWorkspace.OpenConfiguration()) { app, error in
completion?(error == nil)
if let error = error {
Logger().error("Error force launching \(error.localizedDescription)")
} else {