7

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

13

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 
  • It doesn't work with my mac (El-Capitan). – prosseek Feb 11 '16 at 15:10
  • 1
    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. – Pierre Bernard Feb 12 '16 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 – Pierre Bernard Sep 20 '16 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 Mar 25 '17 at 20:21
5

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.

  • It doesn't work with my mac (El-Capitan). – prosseek Feb 11 '16 at 15:05
  • @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 Feb 11 '16 at 15:16
3

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 .