diff --git a/Secretive/Controllers/AgentStatusChecker.swift b/Secretive/Controllers/AgentStatusChecker.swift index ab33384..04b7c0a 100644 --- a/Secretive/Controllers/AgentStatusChecker.swift +++ b/Secretive/Controllers/AgentStatusChecker.swift @@ -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 diff --git a/Secretive/Controllers/LaunchAgentController.swift b/Secretive/Controllers/LaunchAgentController.swift index 97915f8..6d9cf23 100644 --- a/Secretive/Controllers/LaunchAgentController.swift +++ b/Secretive/Controllers/LaunchAgentController.swift @@ -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) } }