-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: separate permission checks for system defaults vs sandboxed def…
…aults
- Loading branch information
1 parent
d3175be
commit 8d07788
Showing
4 changed files
with
35 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { execSync } from "child_process"; | ||
import { getPlatformVersionMajor } from "./getPlatformVersionMajor"; | ||
import { ERR_MACOS_UNABLE_UPDATE_VOICE_OVER_SANDBOXED_DEFAULTS } from "../errors"; | ||
|
||
const VOICE_OVER_APPLESCRIPT_ENABLED_PLUTIL = | ||
"plutil -replace SCREnableAppleScript -bool true ~/Library/Group\\ Containers/group.com.apple.VoiceOver/Library/Preferences/com.apple.VoiceOver4/default.plist"; | ||
|
||
export function enableAppleScriptControlSandboxedDefaults(): void { | ||
const platformMajor = getPlatformVersionMajor(); | ||
|
||
// For MacOS 14 Sonoma (Darwin 23) and earlier VoiceOver preferences are set via system defaults. | ||
if (platformMajor < 24) { | ||
return; | ||
} | ||
|
||
// From MacOS 15 Sequoia (Darwin 24) VoiceOver preferences are sandboxed. | ||
try { | ||
execSync(VOICE_OVER_APPLESCRIPT_ENABLED_PLUTIL, { encoding: "utf8" }); | ||
|
||
return; | ||
} catch (e) { | ||
throw new Error( | ||
`${ERR_MACOS_UNABLE_UPDATE_VOICE_OVER_SANDBOXED_DEFAULTS}\n\n${e.message}` | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters