mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-05-18 23:37:13 +00:00
Auto-register as login item on first launch
This commit is contained in:
parent
d3c4de0375
commit
b3b0dfbf60
1 changed files with 13 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import SwiftUI
|
||||
import AppKit
|
||||
import Observation
|
||||
import ServiceManagement
|
||||
|
||||
private let refreshIntervalSeconds: UInt64 = 15
|
||||
private let nanosPerSecond: UInt64 = 1_000_000_000
|
||||
|
|
@ -50,6 +51,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSPopoverDelegate {
|
|||
setupWakeObservers()
|
||||
setupDistributedNotificationListener()
|
||||
installLaunchAgentIfNeeded()
|
||||
registerLoginItemIfNeeded()
|
||||
Task { await updateChecker.checkIfNeeded() }
|
||||
}
|
||||
|
||||
|
|
@ -133,6 +135,17 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSPopoverDelegate {
|
|||
}
|
||||
}
|
||||
|
||||
private func registerLoginItemIfNeeded() {
|
||||
let service = SMAppService.mainApp
|
||||
if service.status == .notRegistered {
|
||||
do {
|
||||
try service.register()
|
||||
} catch {
|
||||
NSLog("CodeBurn: Login item registration failed: \(error)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func forceRefresh() {
|
||||
Task {
|
||||
await store.refreshQuietly(period: .today)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue