Skip to content

Commit

Permalink
Add ServicesMonitor
Browse files Browse the repository at this point in the history
  • Loading branch information
tekezo committed May 28, 2024
1 parent 22b5706 commit dddbc72
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/apps/SettingsWindow/src/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public class AppDelegate: NSObject, NSApplicationDelegate {
LibKrbn.ConnectedDevices.shared.watch()
LibKrbn.GrabberClient.shared.start()
LibKrbn.Settings.shared.watch()
ServicesMonitor.shared.start()
StateJsonMonitor.shared.start()
SystemPreferences.shared.start()

Expand Down
1 change: 1 addition & 0 deletions src/apps/SettingsWindow/src/ContentViewStates.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ final class ContentViewStates: ObservableObject {
// Alerts
//

@Published public var showServicesNotRunningAlert = false
@Published public var showDriverNotActivatedAlert = false
@Published public var showDriverVersionMismatchedAlert = false
@Published public var showInputMonitoringPermissionsAlert = false
Expand Down
22 changes: 22 additions & 0 deletions src/apps/SettingsWindow/src/ServicesMonitor.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import Foundation

public class ServicesMonitor {
static let shared = ServicesMonitor()

private var timer: Timer?

public func start() {
timer = Timer.scheduledTimer(
withTimeInterval: 3.0,
repeats: true
) { (_: Timer) in
ContentViewStates.shared.showServicesNotRunningAlert =
!libkrbn_services_grabber_daemon_running()
}
}

public func stop() {
timer?.invalidate()
timer = nil
}
}

0 comments on commit dddbc72

Please sign in to comment.