Add notice if agent isn't running (#47)

* Add agent checker
* Check on foreground
This commit is contained in:
Max Goedjen
2020-03-15 14:36:07 -07:00
committed by GitHub
parent bde9085d31
commit 9daae8957a
5 changed files with 87 additions and 9 deletions

View File

@@ -0,0 +1,33 @@
import Foundation
import Combine
import AppKit
protocol AgentStatusCheckerProtocol: ObservableObject {
var running: Bool { get }
}
class AgentStatusChecker: ObservableObject, AgentStatusCheckerProtocol {
@Published var running: Bool = false
init() {
check()
}
func check() {
running = secretAgentProcess != nil
}
var secretAgentProcess: NSRunningApplication? {
NSRunningApplication.runningApplications(withBundleIdentifier: Constants.secretAgentAppID).first
}
}
extension AgentStatusChecker {
enum Constants {
static let secretAgentAppID = "com.maxgoedjen.Secretive.SecretAgent"
}
}