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?

1
  • Considering that there were no answers I converted my partial answer into a full answer.
    – MForster
    Commented Apr 29, 2020 at 7:16

1 Answer 1

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
1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .