15

I’m trying to open the Notifications preference pane (in OS X SystemPreferences.app) via a link. The prefix x-apple.systempreferences:// works so far for opening the system preferences app, but I’d like to open the notifications pane directly and (in the best case) even select my app in the list.

Does anybody know whether the SystemPreferences.app does take any arguments when opened via its URL-Scheme?

I already tried x-apple.systempreferences://Notifications and x-apple.systempreferences://Notifications.prefPane, but the additional arguments are simply ignored.

Thanks!

BTW: Yes, I know I could easily open the Notifications.prefPane file via openFile:, but I’d like to know if it’s possible via URL.

max
  • 1,509
  • 1
  • 19
  • 24

1 Answers1

27

You can open a preference pane via the URL scheme using the preference pane's bundle identifier:

x-apple.systempreferences:com.apple.preference.notifications

If you need to reference an anchor via this scheme you can do so using a query parameter:

x-apple.systempreferences:com.apple.preferences.sharing?Services_ScreenSharing

Note that this scheme is new in 10.10. Use AppleScript or the file open method if support for previous releases is required.

Update: Apple has restricted use of the URL scheme in 10.11. As of this release only preference panes with NSPrefPaneAllowsXAppleSystemPreferencesURLScheme set in their Info.plist can be opened via the URL scheme.

Matt Stevens
  • 13,093
  • 3
  • 33
  • 27
  • 1
    That’s it, thanks! Interestingly this only works without trailing slashes (i.e. `x-apple.systempreferences:...` instead of `x-apple.systempreferences://...`) which makes this scheme unusable from e.g. Safari’s address bar, as Safari doesn’t recognize the scheme without the slashes. – max Jul 12 '14 at 14:06
  • 2
    The default action in Safari for this form is to search, but if you wait for the action menu to appear after typing/pasting in the URL you can select the "Go to Site" option. Embedded links using this scheme also work. – Matt Stevens Jul 12 '14 at 14:18
  • How do you find out how the query parameter is put together? – max Jul 12 '14 at 14:28
  • 11
    The only option is the anchor to display within the opened pane. The easiest way to browse available anchors is probably to use the AppleScript editor. Open System Preferences and select the pane you're interested in, then in the script editor run `tell application "System Preferences" to get anchors of current pane`. – Matt Stevens Jul 12 '14 at 14:52
  • How do you see which are accessible? Safari only seems to offer ability to seatch google – UKDataGeek Sep 09 '16 at 10:11
  • The plist files are found at `/Library/PreferencePanes/paneName.prefPane/Contents/Info.plist` – Zoë Smith Jan 28 '19 at 01:10
  • The .prefPane bundles sometimes contain Plist or XML file with all available identifiers. You can specify them after the `?` symbol in the URL, like the `Services_ScreenSharing` in the example. – Tricertops Nov 21 '19 at 10:19
  • In Big Sur, the system panes seem to be in `/System/Library/PreferencePanes`. – goetz Mar 04 '21 at 13:15