mirror of
https://github.com/maxgoedjen/secretive.git
synced 2025-01-08 12:37:07 +00:00
Switch to SMAppService
This commit is contained in:
parent
c2563be404
commit
28a4dafad4
@ -26,7 +26,7 @@ struct LaunchAgentController {
|
|||||||
let config = NSWorkspace.OpenConfiguration()
|
let config = NSWorkspace.OpenConfiguration()
|
||||||
config.activates = false
|
config.activates = false
|
||||||
do {
|
do {
|
||||||
let app = try await NSWorkspace.shared.openApplication(at: url, configuration: config)
|
try await NSWorkspace.shared.openApplication(at: url, configuration: config)
|
||||||
logger.debug("Agent force launched")
|
logger.debug("Agent force launched")
|
||||||
return true
|
return true
|
||||||
} catch {
|
} catch {
|
||||||
@ -36,8 +36,17 @@ struct LaunchAgentController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func setEnabled(_ enabled: Bool) -> Bool {
|
private func setEnabled(_ enabled: Bool) -> Bool {
|
||||||
// FIXME: THIS
|
let service = SMAppService.loginItem(identifier: Bundle.main.agentBundleID)
|
||||||
SMLoginItemSetEnabled(Bundle.main.agentBundleID as CFString, enabled)
|
do {
|
||||||
|
if enabled {
|
||||||
|
try service.register()
|
||||||
|
} else {
|
||||||
|
try service.unregister()
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
} catch {
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user