EPOD Window Bar is a macOS agent app. It shows a thin strip above the Dock with one tab per window of the frontmost application. One click raises the window. Build from source with XcodeGen and Xcode. Signing uses Config.xcconfig (ad-hoc by default; a local Local.xcconfig can set a team ID). The app needs Accessibility and Screen Recording permissions, and runs in a reduced mode without Screen Recording. See README.md and docs/ for details.
32 lines
1000 B
Swift
32 lines
1000 B
Swift
import Foundation
|
|
import ServiceManagement
|
|
|
|
// LaunchAtLogin controls the login item of EPOD Window Bar. The helper uses
|
|
// SMAppService.mainApp. The helper logs an error and does not crash if the
|
|
// register call or the unregister call fails.
|
|
@MainActor
|
|
enum LaunchAtLogin {
|
|
|
|
// isEnabled is true if the app starts at login.
|
|
static var isEnabled: Bool {
|
|
return SMAppService.mainApp.status == .enabled
|
|
}
|
|
|
|
// setEnabled turns the login item on or off.
|
|
static func setEnabled(_ 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 {
|
|
Log.app.error("Launch at login change failed: \(error.localizedDescription, privacy: .public)")
|
|
}
|
|
}
|
|
}
|