21 lines
527 B
Swift
21 lines
527 B
Swift
import ApplicationServices
|
|
|
|
@MainActor
|
|
enum WindowSwitcherAccessibilityCheck {
|
|
private static let trustedCheckOptionPromptKey = "AXTrustedCheckOptionPrompt"
|
|
|
|
static func isTrusted() -> Bool {
|
|
AXIsProcessTrusted()
|
|
}
|
|
|
|
@discardableResult
|
|
static func requestTrust(prompt: Bool) -> Bool {
|
|
guard prompt else {
|
|
return AXIsProcessTrusted()
|
|
}
|
|
|
|
let options = [trustedCheckOptionPromptKey: true] as CFDictionary
|
|
return AXIsProcessTrustedWithOptions(options)
|
|
}
|
|
}
|