How can I assign actions to all my mouse buttons?

I have a MX Anywhere "M-R0001"

I use my forward and Back buttons as Copy and Paste.

Steps:
1) All buttons are detected with last kernel... at least with

uname -a

3.8.0-25-generic #37-Ubuntu SMP Thu Jun 6 20:47:07 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

2) So, basically, you only need to map those buttons with desired actions. How to know with button is pressed and the correspondent numeric code? Well, you can use the 'xev' program:

xev

This program is a key and mouse events sniffer. When it's running, you can see a window in which you can press mouse buttons and see if they are detected. For example, with the zoom button of the Performance MX you will see something like that:

ButtonPress event, serial 35, synthetic NO, window 0x5800001,
    root 0x15a, subw 0x0, time 64521438, (84,117), root88,144),
    state 0x10, button 13, same_screen YES

that means that 13 is the code for that mouse button. You can try every mouse buttons on your hand ... for easy access, here is the map for Performance MX:

  • Back button: 8
  • Forward button: 9
  • Zoom button: 13
  • Show windows button: 10

the other buttons are well recognized and you don't need to map to actions.

3) Now, you need to install a little program to re-map mouse and keyboard inputs. The magician is 'xbindkeys' ... the easy installation is using:

sudo apt-get install xbindkeys

4) Once installed, you can do the magic. The idea is configure the mouse buttons to send key combinations to activate other desktop functionalities (as the matter of fact, xbindkeys can be used for execute any other program when you press a mouse button). In KDE you can do that with Ctrl+F10 keys combination. The point is create a xbindkeys' configuration file to do the job.

5) To create the configuration file, just run the following command:

xbindkeys --defaults > $HOME/.xbindkeysrc

6) And we need to edit the file to specify your button's mapping:

gedit $HOME/.xbindkeysrc

7) We need to add our button-to-key configurations. For example, I have the following:

# Back changed to Copy
"xte 'keydown Control_L' 'key C' 'keyup Control_L'"
  b:8

# Forward
"xte 'keydown Alt_L' 'key Right' 'keyup Alt_L'"
  b:9

# Present desktops
"xte 'keydown Control_L' 'key F8' 'keyup Control_L'"
  b:13

# Present windows
"xte 'keydown Control_L' 'key F10' 'keyup Control_L'"
  b:10

8) There was a new requirement. the 'xte' program, which basically simulates user key press combinations. Install it using:

sudo apt-get install xautomation

Now, if you run on a terminal something like:

xte 'keydown Control_L' 'key F10' 'keyup Control_L'

that means simulate a Ctrl+F10 keypress. The idea is using xbindkeys to say: "when I press 13th mouse button, send a Ctrl+F10 keyboard press using xte program to generate that"

9) And finally, you need to configure 'xbindkeys' to run automatically on system startup. Startup Applications / Add program button and type '/usr/bin/xbindkeys' on the dialog.

DONE


enter image description here

Easystroke is a Mouse gesture-recognition application and mouse gesture manager for Ubuntu and Other Linux distribution. it allows user to control ubuntu application with hand drawn mouse gestures or Draw on the Screen. Easystroke work on Tablet PCs, it can be used equally well with a mouse, pen, or even your fingers if you have a touch-sensitive screen.

Install Easystroke in Ubuntu

sudo apt-get install easystroke

If you want installing easystroke via PPA, you can adding a PPA repository, type this command:

sudo add-apt-repository ppa:easystroke/ppa
sudo apt-get update
sudo apt-get install easystroke

For Unity Users : EasyStroke have not used indicator applet yet, so when you run it from menu, you have nothing on Indicator Applet. To solve this problem, simply run these command in terminal:

easystroke -g

It will run EasyStroke and open configuration windows automatically.

Source


If all buttons are detected correctly then you can install btnx:

sudo apt-get install btnx OR sudo aptitude install btnx

Then go to: Applications -> System Tools -> Btnx

It has support for many types of mice

Tags:

Mouse