This commit is contained in:
Max Goedjen
2026-06-19 21:53:19 -07:00
parent a727d110c8
commit 98e2f38e46
11 changed files with 116 additions and 53 deletions

View File

@@ -1,4 +1,5 @@
import SwiftUI
import ServiceManagement
import SecretKit
import SecureEnclaveSecretKit
import SmartCardSecretKit
@@ -8,7 +9,7 @@ import CertificateKit
@main
struct Secretive: App {
@Environment(\.agentLaunchController) var agentLaunchController
// @Environment(\.agentLaunchController) var agentLaunchController
@Environment(\.justUpdatedChecker) var justUpdatedChecker
@SceneBuilder var body: some Scene {
@@ -18,15 +19,10 @@ struct Secretive: App {
.environment(EnvironmentValues._certificateStore)
.onReceive(NotificationCenter.default.publisher(for: NSApplication.didBecomeActiveNotification)) { _ in
Task {
@AppStorage("defaultsHasRunSetup") var hasRunSetup = false
@AppStorage("explicitlyDisabled") var explicitlyDisabled = false
guard hasRunSetup && !explicitlyDisabled else { return }
agentLaunchController.check()
guard !agentLaunchController.developmentBuild else { return }
if justUpdatedChecker.justUpdatedBuild || !agentLaunchController.running {
// Relaunch the agent, since it'll be running from earlier update still
try await agentLaunchController.forceLaunch()
}
let service = SMAppService.agent(plistName: "com.maxgoedjen.Secretive.SecretAgent.plist")
try? service.unregister()
try! service.register()
print("Status: \(service.status)")
}
}
}

View File

@@ -100,14 +100,6 @@ struct AgentNotRunningView: View {
explicitlyDisabled = false
guard !loading else { return }
loading = true
Task {
try await agentLaunchController.forceLaunch()
loading = false
if !agentLaunchController.running {
triedRestart = true
}
}
} label: {
if !loading {
Text(.agentDetailsStartAgentButton)

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.maxgoedjen.Secretive.SecretAgent</string>
<key>BundleProgram</key>
<string>Contents/Library/LoginItems/SecretAgent.app/Contents/MacOS/SecretAgent</string>
<key>Sockets</key>
<dict>
<key>SecureListener</key>
<dict>
<key>SecureSocketWithKey</key>
<string>SECRETAGENT_SOCK</string>
</dict>
</dict>
</dict>
</plist>