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)
Tuesday, 21 August 2012
Fixing UK keyboard mapping for Xrdp
Subscribe to:
Post Comments (Atom)
Thanks Robin - I had this issue trying to run my Raspberry Pi "headless" and connecting to it via RDP. I spent much time but only managed to get to the point where I had a new, but broken, km-0809.ini file. Thanks for your perseverance in getting to a full solution.
ReplyDeleteCheers,
Mike
Really appreciate this, someone else was good enough to post it on my SuperUser question about this http://superuser.com/questions/436838/how-do-i-change-the-xrdp-keyboard-layout-to-en-gb-in-ubuntu-12-04 so very grateful to finally have a fix!
ReplyDeleteMany thanks! I was part way through doing exactly what you did when I saw this post. We really need to try to get this into the standard xrdp sources so it flows through to all distributions.
ReplyDeleteDoes anyone have any idea how to do that?
Great - saved me a lot of hassle.
ReplyDeleteWhy xrdp does not include common keyboard layouts by default is a mystery to me.
I have just logged it as a bug with Ubuntu.
Thanks very much ... very helpful for me too
ReplyDeleteWorked like a charm! Thanks a lot for doing the work so we don't have to.
ReplyDeleteHow do we set a different keyboard layout to each user that logins in xrdp?
ReplyDeleteLegend - thank you! Looks like it's working like charm!
ReplyDeleteThank you, you've just saved me loads effort getting my headless pi working.
ReplyDeleteCan I ask for a few hints on which file should I fight with? I'm trying to get xrdp to work with 'Polish Programmers'' layout, where right Alt key is crucial.
ReplyDeleteWorks ok on the console, via xrdp gets somehow screwed (keycode 92 is ok for right Alt, via xrdp it seems to be 113)
Ok, ALMOST nailed it...
ReplyDeleteI did
xrdp-genkeymap for ALL the layouts I have on this test rig in /etc/xrdp (with current settings for pl layout), which gave me diacritics and intended Alt behaviour, the only messed up things seem to be Delete doing PrintScreen and Backspace doing Delete...
Thanks so much for sharing this.
ReplyDeleteSir, you are a wizard. Much obliged.
ReplyDeleteBrilliant - thanks for this - worked a treat
ReplyDeleteUnfortunately this caused my remote keyboard to be none responsive on the RPi. I rebooted the RPi using the local keyboard, but still no joy with the remote keyboard.
ReplyDeleteUsing the local keyboard I removed the km-0809.ini file restarted teh xrdp service but the connection failed, so rebooted the RPi. Keyboard all working on the remote - but in US layout format.
So back to square one. Worth a try though.
I take that all back.
ReplyDeleteMore looking round the web I found everybody points to your site, so it had to be my fault.
I looked at the 0809 file I downloaded and the content was blank. So the file was being applied but there was no mapping! D'oh!!!
Tried it all again and it is now working. Bob on!
Thanks a lot.
This comment has been removed by the author.
ReplyDeleteHi,
ReplyDeleteI have found that the XRDP keyboard layout problem is unsolvable the "easy" way, as things sometimes can be in Linux.
Fortunately, there is a workaround, as there is often in Linux.
Here is a guide I wrote:
http://cloclotron.net/xrdp_keyboard_layout_workaround.html
I spent hours thinking it was the mapping on the OS before the light went on that maybe my issue was due to the fact that I was using xrdp - followed your steps problem solved - awesome!
ReplyDeleteExcellent, thanks for posting this.
ReplyDeleteMany thanks for taking the time to create the file, and make it available.
ReplyDeleteBrilliant, worked a treat and fairly easy for a noob to follow.
ReplyDeleteThank you.
Thank you!
ReplyDeleteI'm a Raspbian new user and when I try to save the ini fiile in the xrdp folder or copy it over I get permission denied. How do I change the permissions to allow this?
ReplyDeleteIn case anyone else has this problem I managed to change the permissions with a bit of help from google...
Delete"sudo chmod -R ugo+rw /etc/xrdp"
Keyboard re-map working great. Thanks.
IMO, one should not "solve" any problem by "opening up" everything to everyone. Even for raspbian, one should think in terms of "admin" functions and "user" functions. I would suggest applying "sudo" to whichever command is being used to save the .ini file in the xrdp folder, rather than changing permissions. That could save you accidentally "blowing away" something in future.
Deletep.s. a (all) is shorthand for ugo, as in a+rw
Thank you. This worked for me now with a Norwegian keyboard layout. I followed the following steps:
ReplyDelete1. downloaded the ini file that is attatched in the first message from https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=709588
2. Saved the file as /etc/xrdp/km-0414.ini
3. Did sudo chown xrdp /etc/xrdp/km-0414.ini
4. Did sudo chgrp xrdp /etc/xrdp/km-0414.ini
5. Rebooted the Raspberry pi and the norwegian keyboard over RDP worked as it should!
Regards, Eirik
Wicked - nice easy little fix
ReplyDeleteThanks
thanks. Very helpful
ReplyDeleteNino
Thank you for sharing this
ReplyDeletePull request created: https://github.com/neutrinolabs/xrdp/pull/416
ReplyDeleteDoes anybody have any suggestions? Robin, did I credit you properly?
thanks for this fix :)
ReplyDeleteACE! Just saved me hours of work! Works a treat :-)
ReplyDeletePaul
Superb!
ReplyDeleteIf you're a noob like me. Download the file and right click on the folder its located in and click 'Open in Terminal'
in the terminal type
sudo cp km-0809.ini /etc/xrdp/
Then you can enter the commands above.
Thank you for this it was driving me insane but your solution just worked
ReplyDeleteHi Robin,
ReplyDeleteI just hit the same problme with remote desktop, and you obviously have found the solution. Unfortunately the download link to the km-0809.ini file, which points to https://sites.google.com/site/componentpart0/km-0809.ini?attredirects=0&d=1 no longer works - I get the message "Site not found". Are you able to reinstate this, or to redirect the link?
Ooops, I cleaned up that site thinking it was unused (and it probably was apart from that one file)
ReplyDeleteRight now I can't find any local backup of the file, but it seems like someone has ripped off my blog post word for word here - http://eurekamoment.eu/?p=144. He has a rar file containing various km-XXXX.ini files including 0809. Maybe the one in that rar is a copy of my original file, certainly would be worth a try.
If you happen to find that it is correct, please let me know and I will re-host it.
km-0809.ini recovered and download link fixed. For reference if the link ever breaks again, the same file can be found here - https://sourceforge.net/p/xrdp/feature-requests/16/
ReplyDeleteI must be doing something wrong, I can't get this to work on Windows 10 and RDP to my Pi. It doesn't seem to change no matter what I do. Tried this tutorial, tried with 00000409.ini (US) nothing changes... Is it possible to do a step by step including checking which keyboard is installed etc.. this kinda drives me nuts. :/
ReplyDelete"Unknown" I think something has changed with the introduction of the new .ini files which now have four zeros in front of the old number. I have a 0809 file that worked on my previous RasPi's but it does not work on the May 2018 release even if I rename it with an additional 4 zeros in the file name. Can't find any help on the web about the changes made with the new filenames.
DeleteWonderful, thanks so much!!! :)
ReplyDeleteIt's the fix that keeps on giving! Thanks very much.
ReplyDeleteI've just started playing with my new RPi and struggled with this for an hour or so before getting a UK keyboard layout to work...
ReplyDelete1. I copied the above km-0809.ini file as /etc/xrdp/km-00000809.ini (after renaming the original just in case)
2. Edited xrdp_keyboard.ini (sudo nano xrdp_keyboard.ini) and added these two lines...
Under [default_rdp_layouts] add
rdp_layout_gb=0x00000809
Then under [default_layouts_map] add
rdp_layout_gb=gb
3. Save the file.
4. Restart the xrdp service...
sudo service xrdp restart
And finally I got # @ £ etc all in the right place!
Initially I wasn't sure whether the keyboard layout should be ...uk or ...gb so I put both in - bad move. It only started to work when I took out the ...uk lines. I'll get used to this linux stuff one day!
Meanwhile thanks to everyone who's contributed to this thread.