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 ] };
Best Answer
I use a regular US keyboard layout, but for all extended characters I mapped the print screen key or the right Windows/Super key to be the compose key. So now when I need a ç I type PrtSc followed by the c and , keys. Similarly for characters like ß (PrtScss) or © (PrtScOc).
See the Wikipedia entry on the compose key for more information. To set the Compose key (in Gnome), you can try Settings → keyboard → Shortcuts tab → compose key option, but that doesn't list the PrtSc key I want, so I did the following:
sudo apt-get install dconf-tools
['compose:prsc']