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.

  • I'd go with Compose Key + a + ". – pLumo Oct 18 '18 at 10:47
  • 1
    One more thing you could do is modifying your keyboard's file in following folder /usr/share/X11/xkb/symbols/, then reboot. You could, this way add third level keys (triggered with AltGr). Obviously, these files may get overwritten by release upgrades. – Johannes Lemonde Oct 18 '18 at 11:50
  • 1
    @Ralf : Actually no, you can't use AltGr+a/o/u with the international keyboard. The international keyboard only adds dead keys. That means that you have to trigger the dead key first, using AltGr, and type a/o/u then. You can find a whole representation of your currently selected keyboard when you click in the panel bar on the button which shows which keyboard is selected, then "show keyboard disposition" (or similarly translated). – Johannes Lemonde Oct 18 '18 at 17:45
  • 1
    @Ralf : using myself several languages, I think however that the other solution, modifying /usr/share/X11/xkb/symbols/us, is more satisfying for performance users. But think to save a copy of the file after you modified it because it might get replaced by the original one after some updates (happens 2 or 3 times a year, usually after Ubuntu release). – Johannes Lemonde Oct 18 '18 at 17:48
  • 1
    This answer shows an example of how the us symbols file can be edited (even if the question was about Swedish extra letters): askubuntu.com/questions/873933/… – Gunnar Hjalmarsson Oct 18 '18 at 23:44

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
<         type= "ALPHABETIC",
<         symbols[Group1]= [               u,               U ]
>         type= "FOUR_LEVEL_ALPHABETIC",
>         symbols[Group1]= [               u,               U,      udiaeresis,      Udiaeresis ]
<         type= "ALPHABETIC",
<         symbols[Group1]= [               o,               O ]
>         type= "FOUR_LEVEL_ALPHABETIC",
>         symbols[Group1]= [               o,               O,      odiaeresis,      Odiaeresis ]
<         type= "ALPHABETIC",
<         symbols[Group1]= [               a,               A ]
>         type= "FOUR_LEVEL_ALPHABETIC",
>         symbols[Group1]= [               a,               A,      adiaeresis,      Adiaeresis ]
<         type= "ALPHABETIC",
<         symbols[Group1]= [               s,               S ]
>         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):

<     key <AD07> {  [     u,    U, udiaeresis, Udiaeresis ] };
>     key <AD07> {  [     u,    U       ]   };
<     key <AD09> {  [     o,    O, odiaeresis, Odiaeresis ] };
>     key <AD09> {  [     o,    O       ]   };
<     key <AC01> {  [     a,    A, adiaeresis, Adiaeresis ] };
<     key <AC02> {  [     s,    S, ssharp, ssharp ] };
>     key <AC01> {  [     a,    A       ]   };
>     key <AC02> {  [     s,    S       ]   };

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.