mirror of
https://github.com/maxgoedjen/secretive.git
synced 2025-04-20 06:22:12 +00:00
Add force launch.
This commit is contained in:
parent
46797ec2a4
commit
0ba2e4107b
@ -1,13 +1,28 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import ServiceManagement
|
import ServiceManagement
|
||||||
|
import AppKit
|
||||||
|
import OSLog
|
||||||
|
|
||||||
struct LaunchAgentController {
|
struct LaunchAgentController {
|
||||||
|
|
||||||
func install() -> Bool {
|
func install() -> Bool {
|
||||||
|
Logger().debug("Installing agent")
|
||||||
_ = setEnabled(false)
|
_ = setEnabled(false)
|
||||||
return setEnabled(true)
|
return setEnabled(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func forceLaunch() {
|
||||||
|
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
|
||||||
|
if let error = error {
|
||||||
|
Logger().error("Error force launching \(error.localizedDescription)")
|
||||||
|
} else {
|
||||||
|
Logger().debug("Agent force launched")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private func setEnabled(_ enabled: Bool) -> Bool {
|
private func setEnabled(_ enabled: Bool) -> Bool {
|
||||||
SMLoginItemSetEnabled("com.maxgoedjen.Secretive.SecretAgent" as CFString, enabled)
|
SMLoginItemSetEnabled("com.maxgoedjen.Secretive.SecretAgent" as CFString, enabled)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user