Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swift 6 / Concurrency fixes #578

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
Switch to SMAppService
maxgoedjen committed Jan 4, 2025
commit 28a4dafad4449fc1f212a3677178cb36111a9519
15 changes: 12 additions & 3 deletions Sources/Secretive/Controllers/LaunchAgentController.swift
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ struct LaunchAgentController {
let config = NSWorkspace.OpenConfiguration()
config.activates = false
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")
return true
} catch {
@@ -36,8 +36,17 @@ struct LaunchAgentController {
}

private func setEnabled(_ enabled: Bool) -> Bool {
// FIXME: THIS
SMLoginItemSetEnabled(Bundle.main.agentBundleID as CFString, enabled)
let service = SMAppService.loginItem(identifier: Bundle.main.agentBundleID)
do {
if enabled {
try service.register()
} else {
try service.unregister()
}
return true
} catch {
return false
}
}

}