Search code examples
macoscocoaurl-schemesystem-preferences

OS X System Preferences URL Scheme


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.


Solution

  • 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.