mirror of
https://github.com/maxgoedjen/secretive.git
synced 2025-08-19 11:40:56 +00:00
* Enable language mode
* WIP
* WIP
* Fix concurrency issues in SmartCardStore
* Switch to SMAppService
* Bump runners
* Base
* Finish Testing migration
* Tweak async for updater
* More
* Backport mutex
* Revert "Backport mutex"
This reverts commit 9b02afb20c
.
* WIP
* Reenable
* Fix preview.
* Update package.
* Bump to latest public macOS and Xcode
* Bump back down to 6.1
* Update to Xcode 26.
* Fixed tests.
* More cleanup
* Env fixes
* var->let
* Cleanup
* Persist auth async
* Whitespace.
* Whitespace.
* Cleanup.
* Cleanup
* Redoing locks in actors bc of observable
* Actors.
* .
* Specify b5
* Update package to 6.2
* Fix disabled updater
* Remove preconcurrency warning
* Move updater init
53 lines
1.3 KiB
Swift
53 lines
1.3 KiB
Swift
import Foundation
|
|
import Combine
|
|
import AppKit
|
|
import SecretKit
|
|
import Observation
|
|
|
|
@MainActor protocol AgentStatusCheckerProtocol: Observable, Sendable {
|
|
var running: Bool { get }
|
|
var developmentBuild: Bool { get }
|
|
func check()
|
|
}
|
|
|
|
@Observable @MainActor final class AgentStatusChecker: AgentStatusCheckerProtocol {
|
|
|
|
var running: Bool = false
|
|
|
|
nonisolated init() {
|
|
Task { @MainActor in
|
|
check()
|
|
}
|
|
}
|
|
|
|
func check() {
|
|
running = instanceSecretAgentProcess != nil
|
|
}
|
|
|
|
// All processes, including ones from older versions, etc
|
|
var secretAgentProcesses: [NSRunningApplication] {
|
|
NSRunningApplication.runningApplications(withBundleIdentifier: Bundle.main.agentBundleID)
|
|
}
|
|
|
|
// The process corresponding to this instance of Secretive
|
|
var instanceSecretAgentProcess: NSRunningApplication? {
|
|
let agents = secretAgentProcesses
|
|
for agent in agents {
|
|
guard let url = agent.bundleURL else { continue }
|
|
if url.absoluteString.hasPrefix(Bundle.main.bundleURL.absoluteString) {
|
|
return agent
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
|
|
// Whether Secretive is being run in an Xcode environment.
|
|
var developmentBuild: Bool {
|
|
Bundle.main.bundleURL.absoluteString.contains("/Library/Developer/Xcode")
|
|
}
|
|
|
|
}
|
|
|
|
|