Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking for a way to swap the left/right button on my mouse (left/right handed person) via the Terminal.

Currently every time I want to switch this I need to go to System Preferences » Mouse » Change the option for Secondary click. It would be much easier to just run a quick command in the terminal.

I've seen things like this: defaults write GlobalPreferences -1

tl;dr: Is there a way to do this sort of command (above) for the mouse's secondary click via the terminal?

My OS is 10.7.5.

share|improve this question
Just a question. Why do you need to constantly switch? I'm just interested. Is the computer is being used bu multiple people or something? – Josiah Nov 16 '12 at 23:50
up vote 1 down vote accepted

The relevant command is:

defaults -currentHost write .GlobalPreferences -bool true

(or "false" to set it back to normal.) However, I don't know of a way to get the setting to take effect without logging out & back in, which is generally more trouble than using System Preferences to make the change.

share|improve this answer
Thanks man! Exactly what I asked. I was bummed out by the fact that I had to logout/login so I did a bit of research. I'll add my finding. – iDev247 Nov 17 '12 at 5:43

I finally went with this solution.

Another tip that I found in this question is to add the script to the menu bar by doing this:

  1. Open AppleScripts Editor (I just search on Spotlight)
  2. If you don't already have the scripts icon in the menu bar:
    1. Click on AppleScripts Editor in the menu bar
    2. Click Preferences
    3. Enable the checkbox Show Script menu in menu bar. I personally prefer unchecking Show Computer script.
  3. Click on the scripts icon that is now showing on your menu bar
  4. Click on Open Scripts Folder and select Open User Script Folder
  5. Save or copy your script file in this folder (the script I'm using can be found here)
  6. When you want to run the script just click the script icon and select the script
share|improve this answer

Here is a simpler script that toggles the setting and doesn't activate System Preferences:

tell application "System Preferences"
    reveal pane ""
end tell
tell application "System Events" to tell process "System Preferences"
    tell radio group 1 of window 1
        if value of radio button 1 is 1 then
            click radio button 2
            click radio button 1
        end if
    end tell
end tell
quit application "System Preferences"

It doesn't work with the Magic Mouse version of the preference pane.

You can save the script in AppleScript Editor and run it with osascript script.scpt. Or see this question for different ways to assign shortcuts to scripts.

share|improve this answer
He said "via terminal". – Micheal Johnson Oct 4 '15 at 14:35

You must log in to answer this question.

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