To create a double-click event when a button is released, I added the following: "/usr/bin/xte 'mouseclick 1' 'mouseclick 1' &" We will use the xte component of xautomation to send events directly to the input handler. The first line is a command to be executed for an event the second line is the event description. The format of this file is a series of paired lines. In my case, I wanted to map the bottom side button (#8) to a double-click of the left button (#1).Ĭreate or edit ~/.xbindkeysrc. Use xinput list and xinput test to discover your mouse's device ID and the number of the button you want to assign. You will need xinput, xbindkeys, and xautomation (including xte) installed for this task. Mapping Mouse Buttons to Arbitrary Functions This will not cause problems if the mouse doesn't report itself as both, so it's been included in the script. Update: As points out below, if your device reports itself as both a mouse and a keyboard, you may need to limit the result count of the grep using -m 1. All others remain at their default setting. In the example above, the only change is that button #9 is being re-mapped to mimic button #2. This value is then used in an xinput set-button-map directive, which executes the re-mapping. This is done by greping for the known name of the mouse in the report from xinput, then using sed to extract the ID number from that id=xxx token in the report. The first line here sets a temporary session variable equal to the ID of the mouse as reported by xinput. # Map button 9 (top side button) to button 2 (middle button) Now that you know what your mouse is called, and which buttons you want to change, you can write an ~/.xsessionrc script that invokes xinput to execute the button re-mapping at startup. In this case I found that I want to map button #9 (side, top) to button #2 (middle). A common re-map reverses these to make the mouse left-handed.) button press 2 (For reference, 1, 2, and 3 "always" (i.e., usually) refer to the left, middle, and right buttons of a 3-button mouse. Press the mouse buttons you want to map from and to, in order to get their indices. Now that you know its name, you can use xinput test deviceID to figure out which key to remap. You'll have to dynamically parse this at startup and execute your re-map based on the current ID. 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. With my mouse, there are only 9 obvious physical buttons, but xinput reports 16. Type: XIButtonClassīutton labels: "Button Left" "Button Middle" "Button Right" "Button Wheel Up" "Button Wheel Down" "Button Horiz Wheel Left" "Button Horiz Wheel Right" "Button Side" "Button Extra" "Button Forward" "Button Back" "Button Task" "Button Unknown" "Button Unknown" "Button Unknown" "Button Unknown" Logitech USB Laser Mouse id=11 Ĭlass originated from: 11. This may be different from the number of buttons that is apparent on the device. 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 xinput list deviceID. Your mouse will have a different name figuring that out is left as an exercise for the reader. My mouse calls itself Logitech USB Laser Mouse and is shown as id=11. Below is some sample output from my laptop: ⎡ Virtual core pointer id=2 First, use xinput to discover the name that is assigned to your mouse, which is then correlated to an input device ID. You will need xinput installed for this task. Mapping Mouse Buttons to Other Mouse Buttons 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. I also wanted to map the bottom side button (#8) so that it executes a double-click of the left button (#1). So I wanted to automatically remap the top side button (#9 in this case) to the middle button (#2). I dislike this because I'm clumsy and typically end up scrolling the window I'm in when I try to click the wheel. I have a Logitech mouse with 9 buttons, and pressing the "middle button" (#2) involves clicking the scroll wheel.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |