Umlauts with qwerty keyboards

Keyboards with the UK layout (qwerty layout) often lack the ability of typing umlauts in texts. Here I will show how to set up the xmodmap feature to solve this little problem.

Setting up the .xmodrc file

First you have to create the .Xmodmap file in your home directory with the following content:

keycode 49 = grave asciitilde degree
keycode 113 = Mode_switch
keysym e = e E EuroSign
keysym c = c C cent
keysym a = a A adiaeresis Adiaeresis
keysym o = o O odiaeresis Odiaeresis
keysym u = u U udiaeresis Udiaeresis
keysym s = s S ssharp

To test it, open one console window and type in the following command:

bash:~$ xmodmap $HOME/.Xmodmap

That was all! You can now get your umlauts with the key combinations:

Alt-Gr + Shift + s or Alt-Gr + s ß
Alt-Gr + Shift + a Ä
Alt-Gr + a ä
Alt-Gr + Shift + o Ö
Alt-Gr + o ö
Alt-Gr + Shift + u Ü
Alt-Gr + u ü

and the currency symbols

Alt-Gr + e
Alt-Gr + c ¢

Making the changes permanent

It is a bit long winded to call the xmodmap command every time you open a shell. There exist two solutions (perhaps even more) which solve the problem. The first is the easiest one: Log off and log in again. The system is automatically aware of the new .Xmodmap configuration file and loads its content to the X window system. It might be the case that the filename ".Xmodmap" is not appropiate for your system. Check /usr/lib/X11/xinit/xinitrc or $HOME/.xinitrc for the right name and change the .Xmodmap. If the first solution doesn't work, the second one comes into account: Open your .bashrc file (I assume that you are working with the bash which is the standard shell in most cases) in your home directory and insert the following lines:

if [ ${#DISPLAY} -ne 0 ];
    if [ $DISPLAY = ":0.0" ];
        xmodmap $HOME/.Xmodmap

The if statements will prevent that when you're making a remote login (e.g. via ssh) the new key settings are done to other keyboards, too.

Save and close your editor and test it with reopening the bash shell.

Happy umlauting!

Update: Disable the CAPS lock key

The most unuseful key on the keyboard is definitively the caps lock. You can disable it by adding the following line to your new .Xmodmap file:

remove Lock = Caps_Lock

If you haven't already done so, add the code lines in the "Making the changes permanent" section to your .bashrc file.

Author: Christoph Hermes, published: 2007-07-24 09:23:20