mirror of
https://github.com/acamarata/curtain.git
synced 2026-07-01 03:04:25 +00:00
Rework Curtain into a proper menu-bar app (Caffeine-style): - SwiftUI settings window: app, on-start, on-idle, on-end, security, displays - Modular ActionSet/ActionRunner — per-event toggles (disconnect/lock/screen-off/deactivate) - Configurable idle timeout; open-at-login via SMAppService; optional menu bar - Settings persisted in UserDefaults (shared with @AppStorage); salted-SHA256 password - Drawn curtains logo (menu-bar template + offscreen-rendered app icon) - Split into single-responsibility modules with comment blocks
18 lines
707 B
Swift
18 lines
707 B
Swift
import Foundation
|
|
import ServiceManagement
|
|
|
|
/// Purpose: Toggle "open at login" via the modern SMAppService API (macOS 13+).
|
|
/// Only works for a real installed app bundle; a no-op when run loose.
|
|
/// SPORT: MASTER-LOGINITEM
|
|
enum LoginItem {
|
|
static var isEnabled: Bool { SMAppService.mainApp.status == .enabled }
|
|
|
|
static func set(_ on: Bool) {
|
|
do {
|
|
if on { if SMAppService.mainApp.status != .enabled { try SMAppService.mainApp.register() } }
|
|
else { if SMAppService.mainApp.status == .enabled { try SMAppService.mainApp.unregister() } }
|
|
} catch {
|
|
NSLog("Curtain: login item toggle failed: \(error.localizedDescription)")
|
|
}
|
|
}
|
|
}
|