-
-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add notice if agent isn't running (#47)
* Add agent checker * Check on foreground
- Loading branch information
1 parent
bde9085
commit 9daae89
Showing
5 changed files
with
87 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Foundation | ||
import Combine | ||
|
||
class PreviewAgentStatusChecker: AgentStatusCheckerProtocol { | ||
|
||
let running: Bool | ||
|
||
init(running: Bool = true) { | ||
self.running = running | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters