User Tools

Site Tools


ubuntu:mouse:map_mouse_buttons

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
ubuntu:mouse:map_mouse_buttons [2021/10/25 09:50] – [Edit the xbindkeys Configuration File] peterubuntu:mouse:map_mouse_buttons [2021/10/26 14:07] (current) peter
Line 1: Line 1:
 ====== Ubuntu - Mouse - Map Mouse Buttons ====== ====== Ubuntu - Mouse - Map Mouse Buttons ======
 +
 +In most cases, 
 +
 +  * Buttons 1, 2, 3 are interpreted as left, middle, right.
 +  * Logical buttons 4, 5, 6, 7 are usually interpreted as scroll up, down, left, right.
 +  * The fourth and fifth physical buttons on a device will thus send logical buttons 8 and 9.
 +
 +----
  
   * [[Ubuntu:Mouse:Determine the Mouse|Determine the Mouse]].   * [[Ubuntu:Mouse:Determine the Mouse|Determine the Mouse]].
Line 6: Line 14:
 ---- ----
  
-===== Map the Mouse Buttons =====+===== Map Mouse Button to Another Button ===== 
 + 
 +This can be useful for changing the mouse for left-handed people. 
 + 
 +  * The left and right buttons could be swapped around (the 3 and 1 are switched).
  
 <code bash> <code bash>
-xinput set-button-map 8 1 0 3 4 5 6 7 8 9+xinput set-button-map 8 3 2 1 4 5 6 7 8 9
 </code> </code>
  
Line 15: Line 27:
 **NOTE:**  The initial **8** is the Mouse Id as determined above. **NOTE:**  The initial **8** is the Mouse Id as determined above.
  
-  * The remaining **1 0 3 4 5 6 7 8 9** is the 9 mouse buttons as determined above.+  * The remaining **3 2 1 4 5 6 7 8 9** is the 9 mouse buttons as determined above.
  
-  * Here, button 2 is replaced by a zero+  * Usually this would be in the order **1 2 3**where 
-    * This disables this button.+    * **1**: is the left mouse button
 +    * **2**: is the middle mouse button
 +    * **3**: is the right mouse button.
  
-  * For left-handed people, the left and right buttons could be swapped around (the 3 and 1 are switched)+  * Herebutton 3 is swapped with button 1. 
-    * **3 2 1 4 5 6 7 8 9**+    * This means that when the actual left button on the mouse is clicked it results in a right-click
 +    * Also, clicking on the actual right mouse button results in a left-click.
  
 </WRAP> </WRAP>
Line 27: Line 42:
 ---- ----
  
-===== Mapping Mouse Buttons to Arbitrary Functions ===== +===== Disable a Specific Mouse Buttons =====
- +
-==== Install xbindkeys ====+
  
 <code bash> <code bash>
-sudo apt install xbindkeys+xinput set-button-map 8 1 0 3 4 5 6 7 8 9
 </code> </code>
  
-----+<WRAP info> 
 +**NOTE:**  The initial **8** is the Mouse Id as determined above.
  
-==== Install xautomation ====+  * The remaining **1 0 3 4 5 6 7 8 9** is the 9 mouse buttons as determined above.
  
-<code bash> +  * Here, button 2 is replaced by a zero. 
-sudo apt install xautomation +    * This disables this button. 
-</code>+ 
 +</WRAP>
  
 ---- ----
  
-==== Create the xbindkeys Configuration File ====+====== Run at startup ======
  
-<code bash?+One approach is to create a shell script that performs the Mouse Button mapping: 
-xbindkeys --defaults $HOME/.xbindkeysrc+ 
 +<code bash> 
 +echo "xinput --set-button-map 21 3 2 1" leftmouseremap.sh
 </code> </code>
  
-----+Give it executable permission:
  
-==== Edit the xbindkeys Configuration File ====+<code bash> 
 +chmod +x leftmouseremap.sh  
 +</code>
  
-Edit **~/.xbindkeysrc**.+<WRAP info> 
 +**NOTE:**  Either run the script manually, or configure it to automatically run on system reboot.
  
-  * To create a double-click event when button 8 is released, add the following: +  * Follow any process to have this script run at boot if needed.
- +
-<file bash ~/.xbindkeysrc> +
-"/usr/bin/xte 'mouseclick 1' 'mouseclick 1' &" +
-b:8 + Release +
-</file> +
- +
-<WRAP info> +
-**NOTE:**  The format of this file is a series of paired lines.+
  
-  * The first line is a command to be executed for an event; +  * Remember to configure 'xbindkeys' to run automatically on system startup too if needed: 
-  The second line is the event description.+    '/usr/bin/xbindkeys'
  
-Here, the **xte** component of xautomation to send events directly to the input handler. 
 </WRAP> </WRAP>
  
----- 
- 
-==== Additional xbindkeys Configurations ==== 
- 
-Here are some examples of additional entries. 
- 
-<file bash ~/.xbindkeysrc> 
-# 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 
-</file> 
- 
-<WRAP info> 
-**NOTE:**  Configure 'xbindkeys' to run automatically on system startup. 
- 
-  * '/usr/bin/xbindkeys' 
- 
-</WRAP> 
  
 ---- ----
Line 101: Line 90:
  
 http://manpages.ubuntu.com/manpages/focal/man1/xev.1.html http://manpages.ubuntu.com/manpages/focal/man1/xev.1.html
 +
 +https://linux.die.net/man/7/xautomation
 +
 +https://manpages.debian.org/stretch/xautomation/xte.1
ubuntu/mouse/map_mouse_buttons.1635155417.txt.gz · Last modified: 2021/10/25 09:50 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki