Tuesday 21 August 2012

Fixing UK keyboard mapping for Xrdp

Xrdp is a pretty nice tool for accessing a Linux box from Windows - you can use the Windows built in remote desktop client rather than having to install some flavour of VNC. It all just works - nearly...

The trouble is that Xrdp doesn't seem to support X windows keyboard mappings properly. I pretty quickly noticed that my ",@,#,~,\,|,£ characters were behaving as though I had a US keyboard not a UK one.

First point of call was the X keyboard settings UI, which oddly was blank with no additional layouts to choose from or options to set. Going to the same settings under an X login on the machine itself was fine. Hmmm...

A little digging revealed this post which outlines the approach to take to generate a new keyboard map for xrdp. For en-gb you need to create a 'km-0809.ini' file and install it into /etc/xrdp. Unfortunately, while this keyboard map fixed the #,@,| etc characters, it broke the arrow keys, page up, page down, home, end and possibly a whole load of other utility keys too.

Fortunately text based configuration files and a diff viewer (Meld) came to the rescue. I was able to cherry pick the changes that I did want from the 0809 ini file and apply them to a copy of the default US english (0409) ini file. I found the list of key codes that I wanted to move across by using the 'xev' tool to record keypress information on the problem keys.

Once the file was finished, it only needs to be copied to /etc/xrdp/km-0809.ini and given the right ownership and permissions. Then restart the xrdp service and you should be done

Here are the commands (on Ubuntu 12.04) to setup the permissions etc and restart the service

sudo chown xrdp.xrdp /etc/xrdp/km-0809.ini
sudo chmod 644 /etc/xrdp/km-0809.ini
sudo service xrdp restart

Here is the corrected UK English keyboard file : km-0809.ini

Please note that comments on this post have now been disabled due to a big increase in the number of spam comments recently (Jan 2019)