Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ftroncosom/c9528e657e4ac204e88e2e0804d9130b to your computer and use it in GitHub Desktop.
Save ftroncosom/c9528e657e4ac204e88e2e0804d9130b 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