mirror of
https://github.com/maxgoedjen/secretive.git
synced 2024-11-26 07:27:07 +00:00
34 lines
665 B
Swift
34 lines
665 B
Swift
|
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"
|
||
|
}
|
||
|
|
||
|
}
|