ubuntu:mouse:map_mouse_buttons_to_arbitrary_functions
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
ubuntu:mouse:map_mouse_buttons_to_arbitrary_functions [2021/10/25 22:56] – [Create the xbindkeys Configuration File] peter | ubuntu: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: | ||
---- | ---- | ||
Line 53: | Line 49: | ||
<WRAP info> | <WRAP info> | ||
**NOTE: | **NOTE: | ||
+ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | |||
+ | - The first line is a command to be executed for an event; | ||
+ | * The quotation marks ("" | ||
+ | - The second line is the associated mouse button. | ||
+ | * The first mouse button (left) is called b:1, the second b:2 and so forth. | ||
</ | </ | ||
---- | ---- | ||
- | ===== Edit the xbindkeys Configuration File ===== | + | ===== Assign a function to a Mouse Button |
- | Edit **~/ | + | Edit the xbindkeys Configuration file, **~/ |
- | * To create a double-click event when button 8 is released, add the following: | + | Add commands similar to this: |
<file bash ~/ | <file bash ~/ | ||
- | "/usr/bin/xte 'mouseclick 1' 'mouseclick 1' | + | "xte 'keydown Home' 'keyup Home'" |
- | b:8 + Release | + | b:6 |
</ | </ | ||
<WRAP info> | <WRAP info> | ||
- | **NOTE: | + | **NOTE: |
- | * The first line is a command to be executed | + | * Raw keycodes can be used too, for example: < |
- | * The quotation marks ("" | + | "xte ' |
- | * The second line is the event description. | + | m:0x0 + b:6 |
+ | </ | ||
- | * 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: |
- | Here, the **xte** component of xautomation to send events directly to the input handler. | ||
</ | </ | ||
---- | ---- | ||
- | ===== Additional xbindkeys Configurations ===== | + | ==== Another examples |
- | Here are some examples of additional entries. | + | <file bash ~/.xbindkeysrc> |
+ | # Refresh | ||
+ | "xte 'key F5'" | ||
+ | b:4 + control | ||
+ | </ | ||
+ | |||
+ | <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. | ||
+ | |||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== Other examples ==== | ||
<file bash ~/ | <file bash ~/ | ||
- | # Back changed to Copy | + | # Back |
- | "xte ' | + | "xte ' |
- | b:8 | + | b:8 |
# Forward | # Forward | ||
Line 97: | Line 118: | ||
<WRAP info> | <WRAP info> | ||
- | **NOTE: | + | **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. |
</ | </ | ||
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 ~/ |
+ | "/ | ||
+ | b:8 + Release | ||
+ | </ | ||
- | <code bash> | + | <WRAP info> |
- | echo " | + | **NOTE: |
- | </ | + | |
- | Give it executable permission: | + | * The **Release** option catches __release__ events instead of __press__ events. |
+ | </ | ||
- | <code bash> | ||
- | chmod +x leftmouseremap.sh | ||
- | </ | ||
- | <WRAP info> | + | ---- |
- | **NOTE: | + | |
- | * Follow any process to have this script run at boot if needed. | + | ====== Restart xbindkeys ====== |
- | * Remember | + | If any changes are made to the config file then xbindkeys |
- | * '/ | + | |
+ | <code bash> | ||
+ | killall | ||
+ | xbindkeys | ||
+ | </ | ||
- | </ | ||
Line 139: | Line 159: | ||
https:// | https:// | ||
+ | |||
+ | https:// | ||
+ | |||
+ | https:// | ||
+ | |||
ubuntu/mouse/map_mouse_buttons_to_arbitrary_functions.1635202569.txt.gz · Last modified: 2021/10/25 22:56 by peter