better permissions mac
This commit is contained in:
@@ -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{
|
||||
|
||||
Reference in New Issue
Block a user