14

I'm trying to open Preference Pane from command. However, when I invoke open /System/Library/PreferencePanes/Dock.prefPane as in How do you access network preferences from the Terminal?, I get Finder that contains the preference pane opened instead.

What might be a way to open the preference pane? I also tried /System/Library/PreferencePanes/Dock.prefPane/Contents/MacOS/Dock to invoke the binary to have this error message.

-bash: /System/Library/PreferencePanes/Dock.prefPane/Contents/MacOS/Dock: cannot execute binary file

4 Answers 4

20

You can open System Preferences using its URL scheme:

open "x-apple.systempreferences:"

You can jump to a specific anchor on a specific pane using:

open "x-apple.systempreferences:com.apple.preference.keyboard?Text"

You can get the list of panes and anchors using AppleScript:

tell application "System Preferences"
    set myIds to the id of every pane
    set myAnchors to anchors of current pane
end tell 

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.

Source: @Matt Stevens answer

4
  • It doesn't work with my mac (El-Capitan).
    – prosseek
    Commented Feb 11, 2016 at 15:10
  • 2
    Looks like a bug to me. It works for some panes and not for others. E.g. open "x-apple.systempreferences:com.apple.preference.universalaccess?SpeakableItems" works on El Capitan. Commented Feb 12, 2016 at 7:31
  • 1
    Opening the Keyboard pane using the above URL scheme still fails under the latest version of El Capitan. The following script however works: tell application "System Preferences" set the current pane to pane id "com.apple.preference.keyboard" activate end tell Commented Sep 20, 2016 at 14:06
  • 3
    Per this, "Apple has restricted use of the URL scheme in 10.11", which is why it won't go to a specific pane any more.
    – medmunds
    Commented Mar 25, 2017 at 20:21
10

The first command should open System Preferences->Dock. However, if it fails try the following command instead:

open -b com.apple.systempreferences /System/Library/PreferencePanes/Dock.prefPane

-b bundle_indentifier specifies the bundle identifier for the application to use when opening the file.

3
  • It doesn't work with my mac (El-Capitan).
    – prosseek
    Commented Feb 11, 2016 at 15:05
  • 1
    @prosseek Hmm both (your first and my command) work for me in El Capitan. Pierre's first command opens System prefs. His second command doesn't work. I didn't try the 3rd one.
    – klanomath
    Commented Feb 11, 2016 at 15:16
  • Wow, great tip. And unlike the accepted solution, other targets are discoverable. Isn't life just so much easier when everything is a file? Commented Oct 19, 2022 at 23:20
8

Or use open. For the account pane:

open /System/Library/PreferencePanes/Accounts.prefPane/

Find other preference pane paths in:

/System/Library/PreferencePanes/
0

I found using applescript solves this problem easily. (Using AppleScript to click radio buttons)

Make this applescript code and put it into $home/Library/Scripts/Preference Pane directory.

tell application "System Preferences"
    set the current pane to pane id "com.apple.preference.dock"
    activate
end tell

tell application "System Events"
    click radio button "Left" of radio group 1 of window "Dock" of process "System Preferences"
end tell

tell application "System Events"
    click radio button "Bottom" of radio group 1 of window "Dock" of process "System Preferences"
end tell

tell application "System Preferences"
    quit
end tell

Then from the applescript menu, click the dock to reset the location.

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .