27 lines
753 B
Swift
27 lines
753 B
Swift
// LaunchAtLogin.swift
|
|
// GreenshotMac
|
|
|
|
import Foundation
|
|
import ServiceManagement
|
|
|
|
enum LaunchAtLogin {
|
|
static var isEnabled: Bool {
|
|
get { SMAppService.mainApp.status == .enabled }
|
|
set {
|
|
do {
|
|
if newValue {
|
|
if SMAppService.mainApp.status != .enabled {
|
|
try SMAppService.mainApp.register()
|
|
}
|
|
} else {
|
|
if SMAppService.mainApp.status == .enabled {
|
|
try SMAppService.mainApp.unregister()
|
|
}
|
|
}
|
|
} catch {
|
|
NSLog("GreenshotMac: could not change launch at login: \(error.localizedDescription)")
|
|
}
|
|
}
|
|
}
|
|
}
|