3

I am the (sad) owner of an otherwise-nice ASUS laptop where ASUS decided that it would be a great idea to replace the End key by Power, so you could accidentally poweroff your laptop when mispressing PgDn (see this question for the photo)...

I initially wanted to use the numeric keypad Home/7 and End/1, and it works (when Num lock is off), but when I press Shift + Home, to select the whole line, I get 7 ... unless Num lock is on, but then I get 7 instead of Home.

So I used remapped the keys with xmodmap to get Home and End behaviour with all modifiers:

keycode  79      = Home Home Home Home U2196 U21D6
keycode  87      = End End End End U2199 U21D9

Unfortunately, it's not working anymore since I upgraded to Ubuntu 18.04 with Wayland. Worse: it's actually working in Firefox but not in Eclipse...

I read many posts about different remapping techniques that were either outdated or too complex to put in place. Now that xmodmap is kind of deprecated, is there an equivalent in Wayland to remap keys with modifiers (I would be happy with (Shift+)Fn+key too)?

Flimm
  • 41,766
Matthieu
  • 476

2 Answers2

3

Just for the record, in case someone needs a quick recipe for swapping keys on Wayland (done on Ubuntu 18.04 LTS).

I've got a dumb layout on my notebook keyboard, and needed to swap the "right shift" and the "?" keys. So, following the advice from https://askubuntu.com/a/1023182/976363 I simply edited /usr/share/X11/xkb/keycodes/evdev as root, swapping the keycodes for both keys.

    <RTSH> = 62;
    ...
    <AB11> = 97;

became

    <RTSH> = 97;
    ...
    <AB11> = 62;

The actual key labels depend on your keyboard layout, which should be looked up in /usr/share/X11/xkb/symbols/.

  • Sounds so straightforward... I'll try to check that tomorrow and will get back to you asap. Though it might mess things up of you plug an external keyboard? – Matthieu Jul 17 '19 at 22:22
  • Yes, I believe any external keyboard would get the same remapping as well. – mgmalheiros Jul 18 '19 at 23:53
  • Some lines have a defined section, like this: <I171> = 171; // #define KEY_NEXTSONG 163 . How do I edit this line? – Flimm Jul 22 '21 at 12:15
  • It seems that // starts a standard comment, so you can just ignore it.

    The #define part looks to be from the input.h header file from the Linux kernel, so it is just documenting the key code mapping between Linux terminal and X11...

    – mgmalheiros Jul 23 '21 at 13:33
1

I stopped using "Ubuntu on Wayland" as the Display Server and chose "Ubuntu" instead (which is on X11, where xmodmap is working fine).

But I would be really glad to switch back to Wayland (or until I change my laptop).

Matthieu
  • 476