How can I set up a mouse scroll button in Wayland with evdev?

With Xorg, I have a config file that allows me to click one particular button on my trackball mouse to switch the ball so it scrolls within a window (very useful in GIMP) rather than moving the pointer, viz:

Option "ScrollMethod" "button"
Option "ScrollButton" "9"

Under Wayland this doesn’t work (not surprisingly), so instead I need a file in /etc/udev/hwdb.d. I’ve successfully remapped one of the buttons to act as a middle button so I can use it to paste:

KEYBOARD_KEY_90005=btn_middle

which proves I’m on the right lines. But I seem to be unable to work out (or find from a search) the right keyword to enable another button to be the scroll button. I’ve tried various ideas, such as

KEYBOARD_KEY_90004=scrolling_button
KEYBOARD_KEY_90004=scrollingbutton
KEYBOARD_KEY_90004=scrollbutton
KEYBOARD_KEY_90004=scroll_button

libinput list-devices tells me that my mouse has “button” set as scroll method, which seems right (though I’ve tried setting it in my udev file)

I’ve identified the right button using evtest in the same way I identified the one I want to emulate middle, so I’m confident I’m doing that bit right. Does anyone know the right keyword for this?

I think KEYBOARD_KEY_90004=btn_middle is already the default for paste (at least in Plasma), and KEYBOARD_KEY_90005=btn_extra seems to be left available for other uses.

While that might suggest I know what I’m typing about, I actually don’t; as it was something I gleaned from a quick Internet search, a few minutes ago.

Nonetheless, maybe it’s as simple as:

KEYBOARD_KEY_90004=btn_scroll

or something similar; have you tried btn_scroll?


There might be something useful in this StackExchange link:

I notice a GUI app input-remapper is mentioned as supporting both X11 and Wayland. The input-remapper-bin binary is available from AUR:

pamac build input-remapper-bin

I also found keymapper but I’m uncertain if Wayland is supported:

Hope this helps to some extent.

Regards.

It is. However, on my tackball, that’s triggered by pressing on the scrollwheel (risking me scrolling as I try). So it’s better for me to re-map it to one of the two extra buttons.

I have now . Sadly still no-go, but thanks for the suggestion.

My previous post has been updated.

Cheers.

Thanks. I’d actually tried input-remapper, but that also requires me to know what keyword to use.
With even more searching I’ve discovered I can do this using qdbus, so I’ve added the solution to this thread.

After much more searching I’ve discovered that this seems to be impossible using libinput, but it can be done using qdbus.

qdbus org.kde.KWin /org/kde/KWin/InputDevice/event2 org.kde.KWin.InputDevice.scrollOnButtonDown true
qdbus org.kde.KWin /org/kde/KWin/InputDevice/event2 org.kde.KWin.InputDevice.scrollButton 265

“event2” is identified as the one for my mouse by running sudo evtest, looking for the name of the mouse then working through the various entries for it to find the right one. Select an option then click the button you want to use (if you’ve selected the wrong input device nothing will happen). The required button (in my case 265) can then be identified from the “code” output to your terminal.

[edit]: OK, so now I find that the button code changes between sessions , which doesn’t make life simple. But fortunately it can be scripted up with
sudo evemu-describe /dev/input/event2 | grep BTN_SIDE | awk '{print $4}'
where “event2” is the device I’ve identified as my mouse and “BTN_SIDE” is the name of the button I need to remap. Made simpler in a startup script by adding evemu-describe to the sudoers file.

The OP seems to have solved their own issue.

I’ll drop this link for the benefit of passers-by as it contains possibly useful reference:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.