3

I want to extend my XKB keyboard layout to add custom bindings. Based on a pc104/us layout I want to add bindings like these:

AltGr-a → ä (adiaeresis)
AltGr-e → € (EuroSign)

I think I know how to accomplish that using xkbcomp. However I'm undecided whether it's preferable to put the additional bindings into level 3 (setxkbmap -option lv3:ralt_switch) or group 2 (setxkbmap -option grp:switch). What are the pros and cons?

MForster
  • 141

1 Answers1

1

Both work. The main pros and cons are around compatibility:

  • XKB itself uses level 3, e.g., for setxkbmap -layout us -variant euro or setxkbmap -option keypad:oss. Putting symbols into level 3 ensures compatibility with that.

  • Group 2 ensures compatibility with xmodmap, which puts additional symbols there. xmodmap is deprecated, but it is still a nice shorthand to quickly add additional bindings.

Here is a solution that uses level 3:

xkbcomp - :0 <<EOF
  xkb_keymap {
    xkb_keycodes { include "evdev+aliases(qwerty)"  };
    xkb_types    { include "complete"  };
    xkb_compat   { include "complete"  };
    xkb_symbols  { include "pc+us+inet(evdev)+level3(ralt_switch)+compose(caps)+keypad(oss)"
      key <LatA> { [ a, A, adiaeresis, Adiaeresis ] };  
      key <LatE> { [ e, E, EuroSign ] };  
      key <LatO> { [ o, O, odiaeresis, Odiaeresis ] };  
      key <LatS> { [ s, S, ssharp ] };  
      key <LatU> { [ u, U, udiaeresis, Udiaeresis ] };  
    };
    xkb_geometry { include "pc(pc104)"  };
  };
EOF
MForster
  • 141
  • 1
    Conventionally, AltGr is indeed level 3 shift. Per ISO/IEC 9995-2, group 2 latch is a different chord. See https://unix.stackexchange.com/a/583088/5132 for more. – JdeBP Apr 29 '20 at 08:53