How to access libinput properties in Wayland for an external touchpad?

First up, libinput by itself is only a library with intentionally no user configuration mechanism. This means you rely on whatever gives you access to libinput functionality. For X11 that’s the libinput driver, which lets you configure properties through xinput.

On Wayland, the compositor has exclusive access to the libinput API, so any configuration needs to be made through KWin.

The straightforward way to modify KWin configs would be through the Touchpad module in System Settings. It doesn’t distinguish between internal or external touchpads, only whether libinput classifies the device as “touchpad”. If you have more than one, it should show a device selection dropdown with all of your touchpads, and you can configure them individually (that’s if I’m reading the code correctly).

The programmatic way would be through D-Bus calls. KWin exposes all of its input devices on the session (user) bus, the service’s bus name being org.kde.KWin, object path org/kde/KWin/InputDevice/event<N> (one for every input device, with <N> starting at 0) and interface org.kde.KWin.InputDevice. You’d want to find your device by looking at the name property, and then set the naturalScroll property of the same event<N> D-Bus object to true. I like to use qdbus to explore this with a GUI (it can also set these properties), or busctl via CLI if it needs to go into a script.

The Touchpad settings module also just uses D-Bus internally btw. As far as I can tell, KWin will store the configuration whenever you update a property for an input device.

You can also call sudo libinput list-devices to get a quick sense of what devices are recognized by libinput (and subsequently available through KWin).

Use whatever works for you! :slight_smile:

3 Likes