I struggled with this over the weekend, and need to remap my mouse buttons.
|
I have a Logitech mouse with 9 buttons, and pressing the "middle button" (#2) involves clicking the scroll wheel. I dislike this because I'm clumsy and typically end up scrolling the window I'm in when I try to click the wheel. So I wanted to automatically remap the top side button (#9 in this case) to the middle button (#2). I also wanted to map the bottom side button (#8) so that it executes a double-click of the left button (#1). Though my aims were specific, the solutions below can be generalized to any situation in which you want to automatically remap mouse buttons at startup. Mapping Mouse Buttons to Other Mouse ButtonsYou will need
My mouse calls itself While you still know the ID of the device in this session, find out how many buttons the input handler thinks your mouse has, by using
With my mouse, there are only 9 obvious physical buttons, but Given the nature of USB, this ID can change every time you restart, so it's not enough to script something that's statically keyed to an ID you discover once. You'll have to dynamically parse this at startup and execute your re-map based on the current ID. Now that you know its name, you can use
In this case I found that I want to map button #9 (side, top) to button #2 (middle). Now that you know what your mouse is called, and which buttons you want to change, you can write an
The first line here sets a temporary session variable equal to the ID of the mouse as reported by Mapping Mouse Buttons to Arbitrary FunctionsSee also this answer. You will need Use Create or edit To create a double-click event when a button is released, I added the following:
This configuration maps a sequence of two mouse clicks on button #1 to the release of button #8. (In theory I guess you could map any command to a mouse button, but this is the most common case. See this answer for other practical examples.) Update for 16.04 UbuntuFor users with multiple mice attached to your system, you need to also pass in the ID of the device. This may not apply to all users and was discovered on Ubuntu 16.04 with Unity.
Then modify the .xbindkeysrc file by referencing the id= value from the command output (id=9 in this example):
|
|||||||||||||||||
|
|
I was able to change the mapping of my Logitech mouse's middle button to 'Return' using Easystroke Gesture Recognition which I downloaded from the Ubuntu Software Center. Edit: In the application, you would select Add Action, Name it, select the key type, click on Details and press Enter, hit Record Stroke, and during the prompt press down on the middle button. |
|||||||||||||||||
|
|
Short steps for this are: There is a utility called I will use my ID as example, from my setup, which is 21, then
Now, if you want to, say, swap left and right buttons you simply run
Here we are, remapping is done. For running it at startup just put this into a file:
give it executable permission
Finally, add this to Statrtup Application manually from GUI or , if you want it from CLI, put text below (change paths to yours) inti a file in your
Keep in mind, that with KDE the path would be like |
||||
|
|