Skip to content

Instantly share code, notes, and snippets.

@dagronf
Last active June 30, 2024 12:58
Show Gist options
  • Save dagronf/c1fd2635c99c627bcfb2e7abb3c31a90 to your computer and use it in GitHub Desktop.
Save dagronf/c1fd2635c99c627bcfb2e7abb3c31a90 to your computer and use it in GitHub Desktop.
macOS: Open system preferences at a specified pane using Swift (or Objective-C) using x-apple.systempreferences
// Applescript: tell application "System Preferences" to get anchors of current pane
// Result:
// { anchor "Privacy_Reminders" of pane id "com.apple.preference.security" of application "System Preferences",
// anchor "Privacy_SystemServices" of pane id "com.apple.preference.security" of application "System Preferences",
// anchor "Privacy_Calendars" of pane id "com.apple.preference.security" of application "System Preferences",
// anchor "Firewall" of pane id "com.apple.preference.security" of application "System Preferences",
// anchor "Privacy_Assistive" of pane id "com.apple.preference.security" of application "System Preferences",
// anchor "Privacy_LinkedIn" of pane id "com.apple.preference.security" of application "System Preferences",
// anchor "Privacy_Accessibility" of pane id "com.apple.preference.security" of application "System Preferences",
// anchor "Privacy_Contacts" of pane id "com.apple.preference.security" of application "System Preferences",
// ...
let prefsURL = URL(string: "x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility")!
NSWorkspace.shared.open(prefsURL)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment