A
A
Alexey Murz Korepov2013-08-01 18:01:00
linux
Alexey Murz Korepov, 2013-08-01 18:01:00

How to set element to scroll on middle mouse button press in Linux Xorg?

I would like to make it so that when the middle (or right) mouse button is held down, dragging the mouse up and down scrolls the current interface element up and down, i.e. made scrolling also as if I was dragging the scroll bar on the right. This is how scrolling works on a laptop through the touchpad with two fingers up and down, but there is no touchpad on a full-fledged computer, and I really want to scroll;)
As far as I figured out, you need to dig somewhere in the garden xorg xinput. In theory, such functionality is already in the system, because. when using the touchpad, when you scroll down with two fingers, it works exactly as it should. The question is how to bind the inclusion of this mode to the clamping of the middle mouse button. At the same time, I would like to leave the normal mouse click as a third mouse button click working. Maybe xinput has nothing to do with it and you need to dig into the display manger (I use kdm), but I didn’t find anything similar there either.
Plugins that do this are found for Firefox and Chrome, but I want it to work not only in individual applications, but in all elements of the system at once (I use Ubuntu with the KDE shell, but it also works in GTK applications). Or, if this cannot be done through xorg, then at least some program to run that does this would also be good. For Windows, I have come across such a program (it scrolls the lists by the right button, but that was 5 years ago and I don’t remember the name), but in Linux I can’t find anything how to do it. Please tell me how this can be done or at least in which direction to dig?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
Y
Yaroslav, 2014-12-17
@Murz

That's how I do it.

#!/bin/bash
nova_mouse_id=$(xinput list | grep pointer | grep NOVA | grep -o [0-9][0-9])
xinput set-prop $nova_mouse_id 'Evdev Wheel Emulation' 1
xinput set-prop $nova_mouse_id 'Evdev Wheel Emulation Axes' 6 7 4 5
xinput set-prop $nova_mouse_id 'Evdev Wheel Emulation Button' 3

  1. Find the desired id:
    xinput list
  2. Enable emulation:
    xinput set-prop $mouse_id 'Evdev Wheel Emulation' 1
  3. Set up all four axes:
    xinput set-prop $mouse_id 'Evdev Wheel Emulation Axes' 6 7 4 5
  4. Assign the right mouse button (middle button - number 2):
    xinput set-prop $mouse_id 'Evdev Wheel Emulation Button' 3

A
Alexey Murz Korepov, 2018-07-26
@Murz

For fresh Ubuntu 18.04, the old solution stopped working, so I had to invent a new one - in the /etc/X11/Xsession.d folder, create a file like 99mouse-middle-scroll with something like this:

IDS=`xinput list | grep 'slave  pointer' | grep -v Virtual | grep -o -P 'id=(\d+)' | grep -o -P '\d+'`

for ID in $IDS
do
  xinput set-prop $ID "libinput Scroll Method Enabled" 0, 0, 1
done

E
Eddy_Em, 2013-08-01
@Eddy_Em

As an option: using xlib to “select” the mouse, analyze events and send already changed events to the client. You can look at the xdotool sources to understand how it should work.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question