1

I'm using a US keyboard layout, but occasionally need to type German umlauts. So far I used .Xmodmap with definitions like this

keycode 133 = Mode_switch NoSymbol Mode_switch
keycode  38 = a A adiaeresis Adiaeresis aacute Aacute
keycode  39 = s S ssharp ssharp ssharp section

where I can reach the umlauts and the sharp s via the Windows key plus a/o/u/s. How can I achieve exactly (really got used to it...) the same behavior with the new xkb system (config file /usr/share/X11/xkb/symbols/pc). It looks even more complicated than Xmodmap.

I would appreciate any help.

ThunderBird
  • 1,963
  • 13
  • 22
  • 31
Ralf
  • 181

1 Answers1

1

After some unsuccessful attempts to add my own local xkb/symbols file (see https://askubuntu.com/a/896298/883344 and https://askubuntu.com/a/896297/883344), I went for the solution from https://stackoverflow.com/a/45042841/3852630. By running

% setxkbmap -query

I see that my current layout is us. I dump this layout to my own file and make a copy

% mkdir $HOME/XKB
% cd $HOME/XKB
% xkbcomp -xkb $DISPLAY us.xkb
% cp us.xkb us-altgr-umlaut.xkb

and modified the copy as seen here

% diff us.xkb us-altgr-umlaut.xkb
1224,1225c1224,1225
<         type= "ALPHABETIC",
<         symbols[Group1]= [               u,               U ]
---
>         type= "FOUR_LEVEL_ALPHABETIC",
>         symbols[Group1]= [               u,               U,      udiaeresis,      Udiaeresis ]
1232,1233c1232,1233
<         type= "ALPHABETIC",
<         symbols[Group1]= [               o,               O ]
---
>         type= "FOUR_LEVEL_ALPHABETIC",
>         symbols[Group1]= [               o,               O,      odiaeresis,      Odiaeresis ]
1244,1245c1244,1245
<         type= "ALPHABETIC",
<         symbols[Group1]= [               a,               A ]
---
>         type= "FOUR_LEVEL_ALPHABETIC",
>         symbols[Group1]= [               a,               A,      adiaeresis,      Adiaeresis ]
1248,1249c1248,1249
<         type= "ALPHABETIC",
<         symbols[Group1]= [               s,               S ]
---
>         type= "FOUR_LEVEL_SEMIALPHABETIC",
>         symbols[Group1]= [               s,               S,          ssharp,          ssharp ]

I wrote a small shell script which is located somewhere in my search path which contains the line

xkbcomp -w 0 $HOME/XKB/us-altgr-umlaut.xkb $DISPLAY

Whenever I want to switch to my layout with German umlauts, I run this script. I switch back to the default keyboard mapping by

setxkbmap us

As mentioned in my comment above, I now use AltGr to switch a/o/u/s to ä/ö/ü/ß (decided to reprogram my brain to use AltGr instead of the Windows key which seems to have a special meaning in the Gnome 3 desktop). As described in https://blog.florianheinle.de/englische-tastatur-umlaute (in German), AltGr can be used for switching by starting gnome-tweaks, then going to Keyboard&Mouse -> Additional Layout Options -> Key to choose the 3rd level, and selecting right alt.

The alternative is of course to modify the file us in /usr/share/X11/xkb/symbols, but this may get overwritten at the next update. Anyhow, that would be the diff between the new us file and the old (same name):

26c26
<     key <AD07> {  [     u,    U, udiaeresis, Udiaeresis ] };
---
>     key <AD07> {  [     u,    U       ]   };
28c28
<     key <AD09> {  [     o,    O, odiaeresis, Odiaeresis ] };
---
>     key <AD09> {  [     o,    O       ]   };
33,34c33,34
<     key <AC01> {  [     a,    A, adiaeresis, Adiaeresis ] };
<     key <AC02> {  [     s,    S, ssharp, ssharp ] };
---
>     key <AC01> {  [     a,    A       ]   };
>     key <AC02> {  [     s,    S       ]   };
Ralf
  • 181