User Tools

Site Tools


ubuntu:mouse:map_mouse_buttons_to_arbitrary_functions

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_to_arbitrary_functions [2021/10/25 22:56] – [Create the xbindkeys Configuration File] peterubuntu:mouse:map_mouse_buttons_to_arbitrary_functions [2021/10/26 08:57] (current) peter
Line 9: Line 9:
   * **xvkbd** can send a keyboard key signal or mouse click to other programs.   * **xvkbd** can send a keyboard key signal or mouse click to other programs.
   * **xdotool** can simulate keyboard input and mouse activity, move and resize windows, etc.   * **xdotool** can simulate keyboard input and mouse activity, move and resize windows, etc.
- 
----- 
- 
-[[Ubuntu:Mouse:Map Mouse Buttons to Arbitrary Functions:|Map Mouse Buttons to Arbitrary Functions]] 
  
 ---- ----
Line 53: Line 49:
 <WRAP info> <WRAP info>
 **NOTE:**  The **$HOME/.xbindkeysrc** file could also be created manually. **NOTE:**  The **$HOME/.xbindkeysrc** file could also be created manually.
 +</WRAP>
 +
 +<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;
 +    * The quotation marks ("") around the command is required.
 +  - The second line is the associated mouse button.
 +    * The first mouse button (left) is called b:1, the second b:2 and so forth.
 </WRAP> </WRAP>
  
 ---- ----
  
-===== Edit the xbindkeys Configuration File =====+===== Assign a function to a Mouse Button  =====
  
-Edit **~/.xbindkeysrc**.+Edit the xbindkeys Configuration file, **~/.xbindkeysrc**:
  
-  * To create a double-click event when button 8 is released, add the following:+Add commands similar to this:
  
 <file bash ~/.xbindkeysrc> <file bash ~/.xbindkeysrc>
-"/usr/bin/xte 'mouseclick 1' 'mouseclick 1&+"xte 'keydown Home' 'keyup Home'"   
-b:8 + Release+b:6
 </file> </file>
  
 <WRAP info> <WRAP info>
-**NOTE:**  The format of this file is a series of paired lines.+**NOTE:**  This binds __button 6__ to the __home__ key
  
-  * The first line is a command to be executed for an event; +  * Raw keycodes can be used too, for example: <code> 
-    * The quotation marks ("") around the command is required. +"xte 'keydown Home' 'keyup Home'
-  * The second line is the event description.+m:0x0 + b:6  
 +</code>
  
-  * The first mouse button (left) is called b:1, the second (right) b:2 and so forth.+See[[Ubuntu:Mouse:Map Mouse Buttons to Arbitrary Functions:Identify the key codes to use|Identify the key codes to use]]
  
-Here, the **xte** component of xautomation to send events directly to the input handler. 
 </WRAP> </WRAP>
  
 ---- ----
  
-===== Additional xbindkeys Configurations =====+==== Another examples ====
  
-Here are some examples of additional entries.+<file bash ~/.xbindkeysrc> 
 +# Refresh 
 +"xte 'key F5'" 
 +  b:4 + control 
 +</file> 
 + 
 +<WRAP info> 
 +**NOTE:** This maps: 
 + 
 +  * This will cause the forward mouse button and the CTRL key to emulate pressing the F5 key. 
 +  * This is useful for refreshing a web page without moving your hand off the mouse. 
 + 
 +</WRAP> 
 + 
 +---- 
 + 
 +==== Other examples ====
  
 <file bash ~/.xbindkeysrc> <file bash ~/.xbindkeysrc>
-# Back changed to Copy +# Back 
-"xte 'keydown Control_L' 'key C' 'keyup Control_L'" +"xte 'keydown Alt_L' 'key Left' 'keyup Alt_L'" 
-  b:8+ b:8
  
 # Forward # Forward
Line 97: Line 118:
  
 <WRAP info> <WRAP info>
-**NOTE:**  This maps: +**NOTE:** This maps:
- +
-  * Back button: 8 +
-    * When Button 8 on the mouse is pressed, send a CTRL-C followed by a Key up.+
  
-  * Forward button: 9  +  * Button 8 is mapped to ALT+LEFT. 
-    When Button 9 on the mouse is pressed, send a ALT followed by a Key up.+  * Button 9 is mapped to ALT+RIGHT.
  
 </WRAP> </WRAP>
Line 109: Line 127:
 ---- ----
  
-====== Run at startup ======+==== More complex examples ====
  
-One approach is to create a shell script that performs the Mouse Button mapping:+<file bash ~/.xbindkeysrc> 
 +"/usr/bin/xte 'mouseclick 1' 'mouseclick 1' &" 
 +b:8 + Release 
 +</file>
  
-<code bash+<WRAP info
-echo "xinput --set-button-map 21 3 2 1" > leftmouseremap.sh +**NOTE:**  This maps a double-left-click to button 8.
-</code>+
  
-Give it executable permission:+  * The **Release** option catches __release__ events instead of __press__ events. 
 +</WRAP>
  
-<code bash> 
-chmod +x leftmouseremap.sh  
-</code> 
  
-<WRAP info> +----
-**NOTE:**  Either run the script manually, or configure it to automatically run on system reboot.+
  
-  * Follow any process to have this script run at boot if needed.+====== Restart xbindkeys ======
  
-  * Remember to configure 'xbindkeysto run automatically on system startup too if needed+If any changes are made to the config file then xbindkeys needs to be restarted
-    * '/usr/bin/xbindkeys'+ 
 +<code bash> 
 +killall xbindkeys 
 +xbindkeys 
 +</code>
  
-</WRAP> 
  
  
Line 139: Line 159:
  
 https://linux.die.net/man/7/xautomation https://linux.die.net/man/7/xautomation
 +
 +https://manpages.debian.org/stretch/xautomation/xte.1
 +
 +https://linux.die.net/man/1/xte
 +
  
ubuntu/mouse/map_mouse_buttons_to_arbitrary_functions.1635202569.txt.gz · Last modified: 2021/10/25 22:56 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki