15

I have a basic logitech mouse with 5 buttons: left, right, wheel left, wheel, wheel right.

I used to use wheel left and right for going back and forward in my browser or navigator. Now this doesn't work. I've found many solutions, people telling to install this program or that, didn't seem to work.

4
  • Can you give us a little more detail about what you tried and how that failed? – guntbert Feb 4 '13 at 19:20
  • I just tried three different programs to map keys and/or keyboard shortcuts (one was an ccsm plugin, another one was just a tool I downloaded at the software center and so was the last one). But honestly I forgot their names, and I now upgradede to 12.10 so I doubt if I can find them back =) – Brent Roose Feb 5 '13 at 8:24
  • Please provide additional information by editing your question. Comments might/will get lost some time. – guntbert Feb 5 '13 at 17:24
  • 1
    Possible duplicate of How to configure extra buttons in Logitech Mouse – Serge Stroobandt Jul 4 '19 at 22:40
21
  1. Install the package xautomation, we need the command xte:

    sudo apt-get install xautomation
    
  2. Install the package x11-utils, we need the command xev:

    sudo apt-get install x11-utils
    
  3. Check the code for the two mouse buttons.

    • Start the command xev in a terminal:

      xev
      
    • Move the mouse in the new window

    • Press your wheel left and wheel right.

    In my case, note the output button 6 and button 7:

    ButtonRelease event, serial 36, synthetic NO, window 0x2e00001,
        root 0x233, subw 0x0, time 9222464, (94,21), root:(1774,85),
        state 0x10, button 6, same_screen YES
    
    ButtonPress event, serial 36, synthetic NO, window 0x2e00001,
        root 0x233, subw 0x0, time 9223854, (94,21), root:(1774,85),
        state 0x10, button 7, same_screen YES
    
  4. Edit your xbindkeys configuration, e.g.:

    nano ~/.xbindkeysrc
    

    and add the lines below

    "xte 'keydown Alt_L' 'keydown Left' 'keyup Left' 'keyup Alt_L'"
         b:6
    
    "xte 'keydown Alt_L' 'keydown Right' 'keyup Right' 'keyup Alt_L'"
         b:7
    

    Replace b:6 and b:7 with your numbers of xev output.

    • From man xte:

      key k
            Press and release key k
      
      keydown  k
            Press key k down
      
      keyup k
            Release key k
      
  5. Kill all xbindkeys processes:

    killall xbindkeys
    
  6. Restart xbindkeys with your configuration, e.g.:

    xbindkeys -f ~/.xbindkeysrc
    
5

Fix Scrolling Speed and back/forward buttons on a Logitech G900 (should be the same for this one):

xev didn’t work for my mouse, I used the command xinput to find out the device ID of my mouse first. To list the Input devices:

 # xinput 
⎡ Virtual core pointer                      id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ Logitech Gaming Mouse G900                id=8    [slave  pointer  (2)]
⎜   ↳ Logitech Gaming Mouse G900                id=9    [slave  pointer  (2)]
⎣ Virtual core keyboard                     id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]
    ↳ Power Button                              id=6    [slave  keyboard (3)]
    ↳ Power Button                              id=7    [slave  keyboard (3)]
    ↳ HD Pro Webcam C920                        id=11   [slave  keyboard (3)]
    ↳ Logitech Gaming Mouse G900                id=12   [slave  keyboard (3)]
    ↳ Apple Inc. Magic Keyboard with Numeric Keypad id=10   [slave  keyboard (3)]

and then use xinput test 8 (this is the mouse id, 9 didn't give any output) to find out that the side buttons are actually button 8 and 9 (just press them and look at the output to see which buttons you press).

I have previously installed imwheel to adjust mouse scrolling speed already

Create a .imwheelrc like this:

cat >~/.imwheelrc<<EOF
".*"
None, Up, Button4, 5 
None, Down, Button5, 5
None, Thumb1, Alt_L|Left
None, Thumb2, Alt_L|Right
EOF

Where the ".*" means, use that config for all x-windows. If you want to use that config only in chrome, for example, you could insert there "^google-chrome$".

You can use xprop WM_CLASS | grep -o '"[^"]*"' | head -n 1 and then click a windows, to get the Name which should be in the config.

The None part in the first column means Mouse button klicks are registered without holding any modifier keys (e.g. Shift, Ctrl, Alt) at the same time.

Button4 and Button5 are typically the Mousewheel. The 5 at the end of the line defines the scroll speed (higher is faster, lower is slower)

I have no idea what the ThumbN means.

The Alt_L|Left should emulate holding down the left Alt key (Alt_L), and pressing the left arrow (←) key to go back in the browser. KP_Left instead of Left would also work.

Restart imwheel with killall imwheel and imwheel.

Note: you have to reopen the windows to take effect.

To find the Button Names use the listing by xmodmap -pke or the Graphical interface from it xkeycaps

I used many sources. To honor some of them: Another post on same topic Also about mouses example imwheelrc file

1
  • 1
    FYI, the manual page says, that Thumb1 and Thumb2 are aliases for button 8 and 9. Somehow hidden in the @Repeat section... – Alexander Janssen Mar 14 at 7:50
4

There are multi mouse button instructions here and xorg.conf info here.

Essentially, you mess around with xinput. (Or imwheel for more options.)

First, open a Terminal. List your input devices:

# show all input devices
xinput list

You'll get something like this:

$ xinput list
⎡ Virtual core pointer                          id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ Microsoft Natural® Ergonomic Keyboard 4000        id=11   [slave  pointer  (2)]
⎜   ↳ Evoluent VerticalMouse 4                  id=12   [slave  pointer  (2)]

I have an Evoluent VerticalMouse. You can see the identifier number is 12: "id=12".

I can test my mouse with:

# show all input from device with identifier number 12
xinput test 12

Now when I move my mouse or click, I get output in that terminal telling me what button I pressed. Hit Ctrl-c to end the test.

If your back/forward buttons aren't giving you output, try resetting your button map to the default with set-button-map. Note that I'm using my device name that was output by xinput list:

xinput set-button-map "Evoluent VerticalMouse 4" 1 2 3 4 5 6 7 8 9 10 11 12 13 14

Now try running xinput test with your id. If you're getting correct button responses here, then you just need to figure out the mapping you want and update your xorg.conf. (I don't know how to do that yet.)

1

Scroll up and down with mouse forward and back buttons

First, install the required packages:

$ sudo apt install x11-utils xbindkeys xautomation

Next, use xev provided by x11-utils to detect the exact button numbers of the back and forward buttons of the mouse.

$ xev |grep -A2 ButtonPress

For my wired vertical Anker mouse, back and forward are respectively buttons 8 and 9.

ButtonPress event, serial 37, synthetic NO, window 0x3600001,
    root 0x1da, subw 0x0, time 1708382, (68,54), root:(939,498),
    state 0x10, button 8, same_screen YES
--
ButtonPress event, serial 37, synthetic NO, window 0x3600001,
    root 0x1da, subw 0x0, time 1711030, (69,48), root:(940,492),
    state 0x10, button 9, same_screen YES

wired vertical Anker mouse

Continue by creating a hidden file named .xbindkeysrc in your home directory with the following contents:

"xte 'keydown Down'"
b:8

"xte 'keyup Down'"
b:8 + Release

"xte 'keydown Up'"
b:9

"xte 'keyup Up'"
b:9 + Release

The xte command is provided by the xautomation package.

Finally, log out and in again from the desktop for these changes to take effect. You can now scroll up and down in browsers and other programs by pressing and holding the mouse back and forward buttons.

1
  • I have the same mouse, those buttons used to work out of the box. Suddenly they stopped working, and what's worse, no mouse button events in xev. – Brandlingo Apr 18 '20 at 12:12
1

After much flailing about, I found that to get the two small triangular buttons under the thumb (next to the thumb wheel) to work as back/forward with my Logitech MX Master, I had to:

Install imwheel, and then edit ~/.imwheelrc to look like this:

".*"
None,      Up,   Button4, 5
None,      Down, Button5, 5
Control_L, Up,   Control_L|Button4
Control_L, Down, Control_L|Button5
Shift_L,   Up,   Shift_L|Button4
Shift_L,   Down, Shift_L|Button5
None, Thumb1  , Alt_L|Left
None, Thumb2  , Alt_L|Right

The bottom two lines mean that pressing the lower of the two thumb buttons ("Thumb1", apparently) without holding any modifier keys (e.g. Shift, Ctrl, Alt) at the same time (that's the "None" part) should emulate holding down the left Alt key (Alt_L), and pressing the left arrow () key to go back in the browser.

Similarly, the "Thumb2" line generates the left Alt key plus the right arrow, to go forward.

It looks like there are a number of different ways to do this, but this is what I found and worked for me in Ubuntu 18.04. I had a little trouble interpreting what the man page for imwheel was telling me to do, so I hope this helps someone out.

After you edit the .imwheelrc file, don't forget to restart imwheel to make the changes take effect:

sudo imwheel -k

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.