Wayland+libinput: remap mouse buttons

My Logitech M510 has its side buttons swapped (probably 4 and 5, I’m used to the one closer to wrist being “Browser Forward” and the other one “Browser Back”, but on M510 they are reversed).

How can I configure my system to remap them the way I want?

If possible - only for this mouse model.

There are a number of low-level remapping tools on Linux:
https://wiki.archlinux.org/title/Input_remap_utilities

I’m personally using interception-tools to remap some keys with dual-functions (when tapped vs pressed with another key).

I know that program can detect specific hardware and launch a specific remap pipeline, but it might be a bit too flexible for such a simple key-to-key remap.
Other tools like xremap (not specific to X11) could be simpler than for your usecase :thinking: