Ryan and Debi & Toren

Ubuntu: keyboard shortcut to switch mouse orientation

In order to minimize the risk of repetitive stress injuries, I have learned to use computer mice ambidextrously – I can do it either right or left-handed without any problems.  However, it’s a little more difficult to do it left-handed on my laptop.  And since I dock my laptop in my office to use an external keyboard and left-handed mouse but undock it to teach my classes and use the touchpad right-handed, I find I’m constantly changing the orientation of the mouse, from right-handed to left-handed and back again.  I figured there had to be a way to make this easier, so I asked on the Ubuntu forums and here’s the answer I received that works.

First, open a terminal and type:

sudo gedit /usr/bin/mouse_switch

When the text file opens, add the following to the file then save it:

current_setting=$(gconftool -g /desktop/gnome/peripherals/mouse/left_handed)
$current_setting && new_setting=false || new_setting=true
gconftool -s /desktop/gnome/peripherals/mouse/left_handed -t bool $new_setting

Close the file. Then in the terminal type:

cd /usr/bin

Then type:

sudo chown “user” mouse_switch

(Of course, you need to replace “user” with your username in Ubuntu.)

You may also have to change the properties on the file (mouse_switch in /usr/bin) by right-clicking it, selecting the permissions tab, and selecting the option that it can be executed.

Then, using the menus at the top of the screen, go to System->Preferences->Keyboard Shortcuts.  In the window that comes up, select “Add”.  Then fill out the new window with the following:

Name: mouse_switch
Command: /usr/bin/mouse_switch

Finally, select the keyboard combination you want (CTRL+SHIFT+M is what I use).  Voila, you should now have a keyboard combination that will switch between left-handed and right-handed mouse orientations.

Exit mobile version