better permissions mac

This commit is contained in:
test
2026-06-04 20:41:10 -05:00
parent 4e267f4d36
commit a35de5d129
15 changed files with 256 additions and 10 deletions
@@ -6,6 +6,7 @@ import (
"errors"
"io"
"os"
"os/exec"
"path/filepath"
)
@@ -29,6 +30,30 @@ func DarwinPermissions() map[string]bool {
}
}
func RequestDarwinPermissions(requested []string) map[string]bool {
want := make(map[string]bool, len(requested))
for _, key := range requested {
want[key] = true
}
if len(want) == 0 {
want["accessibility"] = true
want["screenRecording"] = true
want["fullDiskAccess"] = true
}
if want["accessibility"] {
darwinRequestAccessibilityPermission()
}
if want["screenRecording"] {
darwinRequestScreenRecordingPermission()
}
if want["fullDiskAccess"] {
_ = exec.Command("open", "x-apple.systempreferences:com.apple.preference.security?Privacy_AllFiles").Start()
}
return DarwinPermissions()
}
func darwinFullDiskAccessPermission() bool {
home, _ := os.UserHomeDir()
candidates := []string{