Allows auto-launch for every user's build

This commit is contained in:
Alex Lavallee 2020-11-30 18:25:52 -08:00
parent 1e30bb0a63
commit fd9aa80ca8
No known key found for this signature in database
GPG Key ID: 8F315EDD6F62C73B
2 changed files with 5 additions and 4 deletions

View File

@ -9,7 +9,7 @@ protocol AgentStatusCheckerProtocol: ObservableObject {
class AgentStatusChecker: ObservableObject, AgentStatusCheckerProtocol {
@Published var running: Bool = false
let bundleID = Bundle.main.bundleIdentifier?.replacingOccurrences(of: "Host", with: "SecretAgent")
let bundleID = Bundle.main.bundleIdentifier!.replacingOccurrences(of: "Host", with: "SecretAgent")
init() {
check()
@ -21,7 +21,7 @@ class AgentStatusChecker: ObservableObject, AgentStatusCheckerProtocol {
// All processes, including ones from older versions, etc
var secretAgentProcesses: [NSRunningApplication] {
NSRunningApplication.runningApplications(withBundleIdentifier: bundleID ?? "com.maxgoedjen.Secretive.SecretAgent")
NSRunningApplication.runningApplications(withBundleIdentifier: bundleID )
}
// The process corresponding to this instance of Secretive

View File

@ -4,7 +4,8 @@ import AppKit
import OSLog
struct LaunchAgentController {
let bundleID = Bundle.main.bundleIdentifier!.replacingOccurrences(of: "Host", with: "SecretAgent")
func install(completion: (() -> Void)? = nil) {
Logger().debug("Installing agent")
_ = setEnabled(false)
@ -32,7 +33,7 @@ struct LaunchAgentController {
}
private func setEnabled(_ enabled: Bool) -> Bool {
SMLoginItemSetEnabled("com.maxgoedjen.Secretive.SecretAgent" as CFString, enabled)
SMLoginItemSetEnabled(bundleID as CFString, enabled)
}
}