Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Post History

66%
+2 −0
Q&A How do you remap mouse buttons?

Wayland, ideally If you are on Wayland, the blessed way is to use the configuration for your desktop environment (DE) to map mouse keys and other input devices, except for a couple well-known opti...

posted 2mo ago by Michael‭  ·  edited 1mo ago by Michael‭

Answer
#3: Post edited by user avatar Michael‭ · 2024-03-25T18:00:49Z (about 1 month ago)
More formatting inside quote block
  • # Wayland, ideally
  • If you are on Wayland, the blessed way is to [use the configuration for your desktop environment][libinput-de] (DE) to map mouse keys and other input devices, except for a couple well-known options (eg [left-handed mode][lefty] and [middle mouse emulation][middle-mouse]).
  • # Wayland, via [`hwdb`][hwdb]
  • If your DE _doesn't have_ configuration for mouse key bindings, you may be able to mess with the `hwdb` like [this person on Reddit][reddit]. Wayland's current version of `libinput` says [not to do this anymore][wayland-hwdb-deprecated], but if you're stuck you're stuck.
  • ### Get the device ID
  • > ```sh
  • > $ lsusb | grep Kens
  • > Bus 001 Device 008: ID 047d:8018 Kensington
  • > ```
  • ### Get the input events with `evtest`
  • > ```
  • > Event: time 1584228876.372060, -------------- SYN_REPORT ------------
  • > Event: time 1584228877.572302, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90003
  • > Event: time 1584228877.572302, type 1 (EV_KEY), code 275 (BTN_SIDE), value 1
  • > Event: time 1584228877.572302, -------------- SYN_REPORT ------------
  • > ```
  • > I was lucky because I really just wanted to swap two buttons, and `evtest` dumped the supported events when you select your device. You may be able to figure out the key codes to emulate. I did get hung up on `evtest` reporting `BTN_SIDE`, but having to use lower-case `btn_side` in the `hwdb` entry.
  • ### Add changes to the `hwdb`
  • > I'm on Fedora 31, and have been using [hwdb][wayland-hwdb-1.11.3] entry for a while, because I didn't like the default button configuration on my trackball -- they're frankly backwards for a right-handed person, and the Windows software recognized the need to swap them. (note: Indents are important iirc)
  • >
  • > [The] rule in my `hwdb` entry (`evdev:input:b*v047Dp8018*`) is just the USB Vendor + Product
  • >
  • > ```sh
  • > $ cat 90-trackball-buttons.hwdb
  • > # Kensington Expert Mouse Trackball:
  • > # * Rebind top-left from BTN_MIDDLE to BTN_SIDE
  • > # * Rebind top-right from BTN_SIDE to BTN_MIDDLE
  • > evdev:input:b*v047Dp8018*
  • > KEYBOARD_KEY_90003=btn_side
  • > KEYBOARD_KEY_90004=btn_middle
  • >```
  • ### [Reload your `hwdb`][wayland-hwdb-reload]
  • ```sh
  • $ sudo systemd-hwdb update
  • $ sudo udevadm trigger /sys/class/input/eventX
  • ```
  • [libinput-de]: https://wayland.freedesktop.org/libinput/doc/latest/faqs.html#how-do-i-configure-my-device-on-wayland
  • [lefty]: https://wayland.freedesktop.org/libinput/doc/latest/configuration.html#left-handed-mode
  • [middle-mouse]: https://wayland.freedesktop.org/libinput/doc/latest/configuration.html#middle-button-emulation
  • [hwdb]: https://www.mankier.com/7/hwdb
  • [reddit]: https://www.reddit.com/r/linux4noobs/comments/fih5aw/comment/fkiuyui/
  • [wayland-hwdb-deprecated]: https://wayland.freedesktop.org/libinput/doc/latest/device-configuration-via-udev.html#modifying-the-hwdb
  • [wayland-hwdb-1.11.3]: https://wayland.freedesktop.org/libinput/doc/1.11.3/udev_config.html#hwdb
  • [wayland-hwdb-reload]: https://wayland.freedesktop.org/libinput/doc/latest/device-configuration-via-udev.html#reloading-the-hwdb
  • # Wayland, ideally
  • If you are on Wayland, the blessed way is to [use the configuration for your desktop environment][libinput-de] (DE) to map mouse keys and other input devices, except for a couple well-known options (eg [left-handed mode][lefty] and [middle mouse emulation][middle-mouse]).
  • # Wayland, via [`hwdb`][hwdb]
  • If your DE _doesn't have_ configuration for mouse key bindings, you may be able to mess with the `hwdb` like [this person on Reddit][reddit]. Wayland's current version of `libinput` says [not to do this anymore][wayland-hwdb-deprecated], but if you're stuck you're stuck.
  • ### Get the device ID
  • > ```sh
  • > $ lsusb | grep Kens
  • > Bus 001 Device 008: ID 047d:8018 Kensington
  • > ```
  • ### Get the input events with `evtest`
  • > ```
  • > Event: time 1584228876.372060, -------------- SYN_REPORT ------------
  • > Event: time 1584228877.572302, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90003
  • > Event: time 1584228877.572302, type 1 (EV_KEY), code 275 (BTN_SIDE), value 1
  • > Event: time 1584228877.572302, -------------- SYN_REPORT ------------
  • > ```
  • > I was lucky because I really just wanted to swap two buttons, and `evtest` dumped the supported events when you select your device. You may be able to figure out the key codes to emulate. I did get hung up on `evtest` reporting `BTN_SIDE`, but having to use lower-case `btn_side` in the `hwdb` entry.
  • ### Add changes to the `hwdb`
  • > I'm on Fedora 31, and have been using [a] [`hwdb`][wayland-hwdb-1.11.3] entry for a while, because I didn't like the default button configuration on my trackball -- they're frankly backwards for a right-handed person, and the Windows software recognized the need to swap them. (note: Indents are important iirc)
  • >
  • > [The] rule in my `hwdb` entry (`evdev:input:b*v047Dp8018*`) is just the USB Vendor + Product
  • >
  • > ```sh
  • > $ cat 90-trackball-buttons.hwdb
  • > # Kensington Expert Mouse Trackball:
  • > # * Rebind top-left from BTN_MIDDLE to BTN_SIDE
  • > # * Rebind top-right from BTN_SIDE to BTN_MIDDLE
  • > evdev:input:b*v047Dp8018*
  • > KEYBOARD_KEY_90003=btn_side
  • > KEYBOARD_KEY_90004=btn_middle
  • >```
  • ### [Reload your `hwdb`][wayland-hwdb-reload]
  • ```sh
  • $ sudo systemd-hwdb update
  • $ sudo udevadm trigger /sys/class/input/eventX
  • ```
  • [libinput-de]: https://wayland.freedesktop.org/libinput/doc/latest/faqs.html#how-do-i-configure-my-device-on-wayland
  • [lefty]: https://wayland.freedesktop.org/libinput/doc/latest/configuration.html#left-handed-mode
  • [middle-mouse]: https://wayland.freedesktop.org/libinput/doc/latest/configuration.html#middle-button-emulation
  • [hwdb]: https://www.mankier.com/7/hwdb
  • [reddit]: https://www.reddit.com/r/linux4noobs/comments/fih5aw/comment/fkiuyui/
  • [wayland-hwdb-deprecated]: https://wayland.freedesktop.org/libinput/doc/latest/device-configuration-via-udev.html#modifying-the-hwdb
  • [wayland-hwdb-1.11.3]: https://wayland.freedesktop.org/libinput/doc/1.11.3/udev_config.html#hwdb
  • [wayland-hwdb-reload]: https://wayland.freedesktop.org/libinput/doc/latest/device-configuration-via-udev.html#reloading-the-hwdb
#2: Post edited by user avatar Michael‭ · 2024-03-25T17:59:01Z (about 1 month ago)
Main section headings. Link hwdb(7).
  • If you are on Wayland, the blessed way is to [use the configuration for your desktop environment][libinput-de] (DE) to map mouse keys and other input devices, except for a couple well-known options (eg [left-handed mode][lefty] and [middle mouse emulation][middle-mouse]).
  • If your DE _doesn't have_ configuration for mouse key bindings, you may be able to mess with the `hwdb` like [this person on Reddit][reddit]. Wayland's version of `libinput` says [not to do this anymore][no-hwdb], but if you're stuck you're stuck.
  • ### Get the device ID
  • > ```sh
  • > $ lsusb | grep Kens
  • > Bus 001 Device 008: ID 047d:8018 Kensington
  • > ```
  • ### Get the input events with `evtest`
  • > ```
  • > Event: time 1584228876.372060, -------------- SYN_REPORT ------------
  • > Event: time 1584228877.572302, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90003
  • > Event: time 1584228877.572302, type 1 (EV_KEY), code 275 (BTN_SIDE), value 1
  • > Event: time 1584228877.572302, -------------- SYN_REPORT ------------
  • > ```
  • > I was lucky because I really just wanted to swap two buttons, and `evtest` dumped the supported events when you select your device. You may be able to figure out the key codes to emulate. I did get hung up on `evtest` reporting `BTN_SIDE`, but having to use lower-case `btn_side` in the `hwdb` entry.
  • ### Add changes to the `hwdb`
  • > I'm on Fedora 31, and have been using [hwdb] entry for a while, because I didn't like the default button configuration on my trackball -- they're frankly backwards for a right-handed person, and the Windows software recognized the need to swap them. (note: Indents are important iirc)
  • >
  • > [The] rule in my `hwdb` entry (`evdev:input:b*v047Dp8018*`) is just the USB Vendor + Product
  • >
  • > ```sh
  • > $ cat 90-trackball-buttons.hwdb
  • > # Kensington Expert Mouse Trackball:
  • > # * Rebind top-left from BTN_MIDDLE to BTN_SIDE
  • > # * Rebind top-right from BTN_SIDE to BTN_MIDDLE
  • > evdev:input:b*v047Dp8018*
  • > KEYBOARD_KEY_90003=btn_side
  • > KEYBOARD_KEY_90004=btn_middle
  • >```
  • ### [Reload your `hwdb`][hwdb-reload]
  • ```sh
  • $ sudo systemd-hwdb update
  • $ sudo udevadm trigger /sys/class/input/eventX
  • ```
  • [libinput-de]: https://wayland.freedesktop.org/libinput/doc/latest/faqs.html#how-do-i-configure-my-device-on-wayland
  • [lefty]: https://wayland.freedesktop.org/libinput/doc/latest/configuration.html#left-handed-mode
  • [middle-mouse]: https://wayland.freedesktop.org/libinput/doc/latest/configuration.html#middle-button-emulation
  • [reddit]: https://www.reddit.com/r/linux4noobs/comments/fih5aw/comment/fkiuyui/
  • [no-hwdb]: https://wayland.freedesktop.org/libinput/doc/latest/device-configuration-via-udev.html#modifying-the-hwdb
  • [hwdb]: https://wayland.freedesktop.org/libinput/doc/1.11.3/udev_config.html#hwdb
  • [hwdb-reload]: https://wayland.freedesktop.org/libinput/doc/latest/device-configuration-via-udev.html#reloading-the-hwdb
  • # Wayland, ideally
  • If you are on Wayland, the blessed way is to [use the configuration for your desktop environment][libinput-de] (DE) to map mouse keys and other input devices, except for a couple well-known options (eg [left-handed mode][lefty] and [middle mouse emulation][middle-mouse]).
  • # Wayland, via [`hwdb`][hwdb]
  • If your DE _doesn't have_ configuration for mouse key bindings, you may be able to mess with the `hwdb` like [this person on Reddit][reddit]. Wayland's current version of `libinput` says [not to do this anymore][wayland-hwdb-deprecated], but if you're stuck you're stuck.
  • ### Get the device ID
  • > ```sh
  • > $ lsusb | grep Kens
  • > Bus 001 Device 008: ID 047d:8018 Kensington
  • > ```
  • ### Get the input events with `evtest`
  • > ```
  • > Event: time 1584228876.372060, -------------- SYN_REPORT ------------
  • > Event: time 1584228877.572302, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90003
  • > Event: time 1584228877.572302, type 1 (EV_KEY), code 275 (BTN_SIDE), value 1
  • > Event: time 1584228877.572302, -------------- SYN_REPORT ------------
  • > ```
  • > I was lucky because I really just wanted to swap two buttons, and `evtest` dumped the supported events when you select your device. You may be able to figure out the key codes to emulate. I did get hung up on `evtest` reporting `BTN_SIDE`, but having to use lower-case `btn_side` in the `hwdb` entry.
  • ### Add changes to the `hwdb`
  • > I'm on Fedora 31, and have been using [hwdb][wayland-hwdb-1.11.3] entry for a while, because I didn't like the default button configuration on my trackball -- they're frankly backwards for a right-handed person, and the Windows software recognized the need to swap them. (note: Indents are important iirc)
  • >
  • > [The] rule in my `hwdb` entry (`evdev:input:b*v047Dp8018*`) is just the USB Vendor + Product
  • >
  • > ```sh
  • > $ cat 90-trackball-buttons.hwdb
  • > # Kensington Expert Mouse Trackball:
  • > # * Rebind top-left from BTN_MIDDLE to BTN_SIDE
  • > # * Rebind top-right from BTN_SIDE to BTN_MIDDLE
  • > evdev:input:b*v047Dp8018*
  • > KEYBOARD_KEY_90003=btn_side
  • > KEYBOARD_KEY_90004=btn_middle
  • >```
  • ### [Reload your `hwdb`][wayland-hwdb-reload]
  • ```sh
  • $ sudo systemd-hwdb update
  • $ sudo udevadm trigger /sys/class/input/eventX
  • ```
  • [libinput-de]: https://wayland.freedesktop.org/libinput/doc/latest/faqs.html#how-do-i-configure-my-device-on-wayland
  • [lefty]: https://wayland.freedesktop.org/libinput/doc/latest/configuration.html#left-handed-mode
  • [middle-mouse]: https://wayland.freedesktop.org/libinput/doc/latest/configuration.html#middle-button-emulation
  • [hwdb]: https://www.mankier.com/7/hwdb
  • [reddit]: https://www.reddit.com/r/linux4noobs/comments/fih5aw/comment/fkiuyui/
  • [wayland-hwdb-deprecated]: https://wayland.freedesktop.org/libinput/doc/latest/device-configuration-via-udev.html#modifying-the-hwdb
  • [wayland-hwdb-1.11.3]: https://wayland.freedesktop.org/libinput/doc/1.11.3/udev_config.html#hwdb
  • [wayland-hwdb-reload]: https://wayland.freedesktop.org/libinput/doc/latest/device-configuration-via-udev.html#reloading-the-hwdb
#1: Initial revision by user avatar Michael‭ · 2024-03-22T20:59:51Z (about 2 months ago)
If you are on Wayland, the blessed way is to [use the configuration for your desktop environment][libinput-de] (DE) to map mouse keys and other input devices, except for a couple well-known options (eg [left-handed mode][lefty] and [middle mouse emulation][middle-mouse]).

If your DE _doesn't have_ configuration for mouse key bindings, you may be able to mess with the `hwdb` like [this person on Reddit][reddit]. Wayland's version of `libinput` says [not to do this anymore][no-hwdb], but if you're stuck you're stuck.

### Get the device ID

> ```sh
> $ lsusb | grep Kens
> Bus 001 Device 008: ID 047d:8018 Kensington
> ```

### Get the input events with `evtest`

> ```
> Event: time 1584228876.372060, -------------- SYN_REPORT ------------
> Event: time 1584228877.572302, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90003
> Event: time 1584228877.572302, type 1 (EV_KEY), code 275 (BTN_SIDE), value 1
> Event: time 1584228877.572302, -------------- SYN_REPORT ------------
> ```
> I was lucky because I really just wanted to swap two buttons, and `evtest` dumped the supported events when you select your device. You may be able to figure out the key codes to emulate. I did get hung up on `evtest` reporting `BTN_SIDE`, but having to use lower-case `btn_side` in the `hwdb` entry.

### Add changes to the `hwdb`

> I'm on Fedora 31, and have been using [hwdb] entry for a while, because I didn't like the default button configuration on my trackball -- they're frankly backwards for a right-handed person, and the Windows software recognized the need to swap them. (note: Indents are important iirc)
>
> [The] rule in my `hwdb` entry (`evdev:input:b*v047Dp8018*`) is just the USB Vendor + Product
>
> ```sh
> $ cat 90-trackball-buttons.hwdb 
> # Kensington Expert Mouse Trackball:
> # * Rebind top-left from BTN_MIDDLE to BTN_SIDE
> # * Rebind top-right from BTN_SIDE to BTN_MIDDLE
> evdev:input:b*v047Dp8018*
>  KEYBOARD_KEY_90003=btn_side
>  KEYBOARD_KEY_90004=btn_middle
>```

### [Reload your `hwdb`][hwdb-reload]

```sh
$ sudo systemd-hwdb update
$ sudo udevadm trigger /sys/class/input/eventX
```

[libinput-de]: https://wayland.freedesktop.org/libinput/doc/latest/faqs.html#how-do-i-configure-my-device-on-wayland
[lefty]: https://wayland.freedesktop.org/libinput/doc/latest/configuration.html#left-handed-mode
[middle-mouse]: https://wayland.freedesktop.org/libinput/doc/latest/configuration.html#middle-button-emulation
[reddit]: https://www.reddit.com/r/linux4noobs/comments/fih5aw/comment/fkiuyui/
[no-hwdb]: https://wayland.freedesktop.org/libinput/doc/latest/device-configuration-via-udev.html#modifying-the-hwdb
[hwdb]: https://wayland.freedesktop.org/libinput/doc/1.11.3/udev_config.html#hwdb
[hwdb-reload]: https://wayland.freedesktop.org/libinput/doc/latest/device-configuration-via-udev.html#reloading-the-hwdb