- Add AppDiscovery provider for running app enumeration - Implement AppDropdownView with auto-launch functionality - Create SignalAction models for 40+ yabai commands - Build ActionBuilderView with nested parameter controls - Add LiveShellPreview for real-time shell command generation - Implement ActionValidator for conflict detection - Add migration parser for existing raw action strings - Include feature flag for safe rollout - Maintain full backward compatibility
61 lines
1.9 KiB
Swift
61 lines
1.9 KiB
Swift
//
|
|
// PermissionsManager.swift
|
|
// YabaiPro
|
|
//
|
|
// Created by Jake Shore
|
|
// Copyright © 2024 Jake Shore. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
import ApplicationServices
|
|
import AppKit
|
|
import CoreGraphics
|
|
|
|
class PermissionsManager {
|
|
static let shared = PermissionsManager()
|
|
|
|
var hasAccessibilityPermission: Bool {
|
|
// Check without prompting - only returns true/false
|
|
return AXIsProcessTrusted()
|
|
}
|
|
|
|
var hasScreenRecordingPermission: Bool {
|
|
// Check if we have screen recording permission
|
|
// This is a bit tricky - we try to create a screenshot and see if it succeeds
|
|
guard let windowList = CGWindowListCopyWindowInfo(.optionOnScreenOnly, kCGNullWindowID) as? [[String: Any]] else {
|
|
return false
|
|
}
|
|
// If we can get window info, we likely have permission
|
|
return !windowList.isEmpty
|
|
}
|
|
|
|
func requestAccessibilityPermission() {
|
|
let options = [kAXTrustedCheckOptionPrompt.takeUnretainedValue() as String: true]
|
|
AXIsProcessTrustedWithOptions(options as CFDictionary)
|
|
}
|
|
|
|
func requestScreenRecordingPermission() {
|
|
// Trigger screen recording permission by attempting to capture screen
|
|
// This will prompt the user for permission
|
|
_ = CGWindowListCopyWindowInfo(.optionOnScreenOnly, kCGNullWindowID)
|
|
}
|
|
|
|
func openAccessibilitySettings() {
|
|
if let url = URL(string: "x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility") {
|
|
NSWorkspace.shared.open(url)
|
|
}
|
|
}
|
|
|
|
func openScreenRecordingSettings() {
|
|
if let url = URL(string: "x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture") {
|
|
NSWorkspace.shared.open(url)
|
|
}
|
|
}
|
|
|
|
func openPrivacySecuritySettings() {
|
|
if let url = URL(string: "x-apple.systempreferences:com.apple.preference.security?Privacy") {
|
|
NSWorkspace.shared.open(url)
|
|
}
|
|
}
|
|
}
|