Last active
May 1, 2023 19:21
-
-
Save leodutra/d61a9172d9c7cec6783315e3a1df663f to your computer and use it in GitHub Desktop.
Mouse Linux Xmodmap X11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Somehow, I ended up without any xmodmap files on my Ubuntu install, so I had to find a different approach to this problem. | |
Take a look at the **xinput** command. | |
xinput list | grep -i mouse | |
which lists information about your mouse. It shows my mouse is "Dell Premium USB Optical Mouse" and also that I have "Macintosh mouse button emulation". Armed with that info, I can | |
xinput get-button-map "Dell Premium USB Optical Mouse" | |
which gives me a listing that looks like | |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | |
Here is the useful, required knowledge. My mouse has, theoretically, 18 buttons. Each button's default action has the same name as it's button number. In other words, button 1 does action 1, button 4 does action 4, etc. Action 0 means "off". | |
The **position** in the listing shows the function assigned to that button. So if my button map read | |
1 3 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | |
this would mean button 1 (position 1) does action 1 (normal left button), button 2 (position 2) does action 3 (middle button) and button 3 (position 3) does action 2 (right button). | |
To make a left handed mouse all you would need would be a button map that starts | |
3 2 1 4 5 ..... | |
Or, in your case, it looks like you want the middle button to do the same thing as button 1 (left button) so your map needs to start | |
1 1 3 .... | |
I'd reset my mouse button mappings thus: | |
xinput set-button-map "Dell Premium USB Optical Mouse" 1 1 3 5 6 6 7 8 9 10 11 12 13 14 15 16 17 18 | |
In your case, you may have a different number of mapped buttons and have some special button map already defined. Likwely, your mouse has a different name, too. First, get your mouse's "name". Then, use the **get-button-map** operation to find your base button map. finally, use the **set-button-map** option, modifying button 2 to do action 1. | |
This is not a permanent change. I added the necessary code to my *.bashrc* so it executes every time I login or open a terminal. | |
Hope this helps. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment