linux:misc:xrdp_hr_keymap

Fixing HR keyboard mapping for xrdp

After looking into this and trying to assemble information from several sources it starts to make sense. Here is what almost works for me.

  1. Setting right keyboard in X This is done with “setxkbmap <language code>” where language is a two letter code. In my case setxkbmap hr works. A good guide to setxkbmap can be found at http://tldp.org/HOWTO/Intkeyb/x53.html
  2. Convert the X keyboard mapping to the Xrdp keymap format. This is done with the command xrdp-genkeymap ~/km-041a.ini The code 041a is the code for Croatia.,you have to replace this with yours. The complete list of country codes can be found at http://rdesktop.svn.sourceforge.net/...87&view=markup
  3. Enable the KM file. Log in as root and move the produced file with mv ~/km-041a.ini /etc/xrdp/ and then set root as the owner of this file with “chown root:root /etc/xrdp/km-041a.ini”
  4. Edit xrdp_keyboard.ini, and append rdp_layout_hr=0x041a to [default_rdp_layouts] section, and rdp_layout_hr=hr to [default_layouts_map]
  5. Stop the Xrdp server. First find the server processes with ps -A | grep xrdp and then kill nnnn where nnnn is the process id. Both the xrdp and the xrdp-sesman process should be killed.
  6. Restart the Xrdp process. This is done with the command /etc/init.d/xrdp start still as root.

If some keys are not working (eg. @).

After this most of the keyboard is working except for the important AT sign, and some of the other AltGr symbols important for programming like braces and brackets.

The current X key map can be dumped with “xmodmap -pk > mykeys.txt” and mykeys can be opened with a text editor. The columns are

  Key
  Key without any qualifier
  Shift + Key
  AltGr + Key
  Shift + AltGr + Key

The X key map symbols are given in hex while the Xrdp key map file uses the same symbols but converted to decimal values. Normally the same symbol is given before and after the comma, like for the A-key (number 38) Key38=97:97 I have no idea what the colon means, and I have not understood why some keys have different values before and after the colon, but 97 = 0x61, which is just what we find in the X key map file “mykeys.txt”.

The Xrdp keymap file has several sections that are obvious for the alternative alternation keys. For instance this say that for the number two key 11: [altgr] Key11=64:64 and 64 = 0x40 which is exactly the AT sign precisely where it should be on a Croatian keyboard. However, it does not work! It seem that the altgr section is ignored for some reason, and AltGr+2 gives q.

The missing AltGr characters can be defined with the xmodmap command. The general syntax for my @ key at AltGr+2 was

xmodmap -e “keysym 2 = 2 quotedbl at quotedbl at”

Note that all five columns of the previously generated “mykeys.txt” are defined (with the equal sign between the first and the other four). As you can see [@] this works for all the missing AltGr combinations. The names of the symbols, like “quotedbl” for the double string quotes used around the keysym string, can best be found in the the previously generated “mykeys.text” file.

It is impractical to give the above xmodmap for the 8 AltGr+key combinations on the Croatian keyboard missing. The solution is to create an “~/.Xmodmap” file containing only the command strings of the above commands. Mine looks like this:

[~/.Xmodmap:] keysym e = e E EuroSign e EuroSign keysym 0 = 0 equal braceright equal braceright keysym 2 = 2 quotedbl at quotedbl at keysym 3 = 3 numbersign sterling numbersign sterling keysym 4 = 4 currency dollar currency dollar keysym 7 = 7 slash braceleft slash braceleft keysym 8 = 8 parenleft bracketleft parenleft bracketleft keysym 9 = 9 parenright bracketright parenright bracketright

[end]

Old article

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 flavor 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 HR 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 log in on the machine itself was fine. Hmmm…

A little digging revealed a post which outlines the approach to take to generate a new keyboard map for xrdp. For HR you need to create a 'km-0041a.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-041a.ini and given the right ownership and permissions. Then restart the xrdp service and you should be done

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

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

Here is the complete list of key mapping file names and lower is the archive with some of them

rfc1766
 
"hex number"="fiendly name"
 
"0436"="af;Afrikaans"
"041C"="sq;Albanian"
"0001"="ar;Arabic"
"0401"="ar-sa;Arabic (Saudi Arabia)"
"0801"="ar-iq;Arabic (Iraq)"
"0C01"="ar-eg;Arabic (Egypt)"
"1001"="ar-ly;Arabic (Libya)"
"1401"="ar-dz;Arabic (Algeria)"
"1801"="ar-ma;Arabic (Morocco)"
"1C01"="ar-tn;Arabic (Tunisia)"
"2001"="ar-om;Arabic (Oman)"
"2401"="ar-ye;Arabic (Yemen)"
"2801"="ar-sy;Arabic (Syria)"
"2C01"="ar-jo;Arabic (Jordan)"
"3001"="ar-lb;Arabic (Lebanon)"
"3401"="ar-kw;Arabic (Kuwait)"
"3801"="ar-ae;Arabic (U.A.E.)"
"3C01"="ar-bh;Arabic (Bahrain)"
"4001"="ar-qa;Arabic (Qatar)"
"042D"="eu;Basque"
"0402"="bg;Bulgarian"
"0423"="be;Belarusian"
"0403"="ca;Catalan"
"0004"="zh;Chinese"
"0404"="zh-tw;Chinese (Taiwan)"
"0804"="zh-cn;Chinese (China)"
"0C04"="zh-hk;Chinese (Hong Kong SAR)"
"1004"="zh-sg;Chinese (Singapore)"
"041A"="hr;Croatian"
"0405"="cs;Czech"
"0406"="da;Danish"
"0413"="nl;Dutch (Netherlands)"
"0813"="nl-be;Dutch (Belgium)"
"0009"="en;English"
"0409"="en-us;English (United States)"
"0809"="en-gb;English (United Kingdom)"
"0C09"="en-au;English (Australia)"
"1009"="en-ca;English (Canada)"
"1409"="en-nz;English (New Zealand)"
"1809"="en-ie;English (Ireland)"
"1C09"="en-za;English (South Africa)"
"2009"="en-jm;English (Jamaica)"
"2809"="en-bz;English (Belize)"
"2C09"="en-tt;English (Trinidad)"
"0425"="et;Estonian"
"0438"="fo;Faeroese"
"0429"="fa;Farsi"
"040B"="fi;Finnish"
"040C"="fr;French (France)"
"080C"="fr-be;French (Belgium)"
"0C0C"="fr-ca;French (Canada)"
"100C"="fr-ch;French (Switzerland)"
"140C"="fr-lu;French (Luxembourg)"
"043C"="gd;Gaelic"
"0407"="de;German (Germany)"
"0807"="de-ch;German (Switzerland)"
"0C07"="de-at;German (Austria)"
"1007"="de-lu;German (Luxembourg)"
"1407"="de-li;German (Liechtenstein)"
"0408"="el;Greek"
"040D"="he;Hebrew"
"0439"="hi;Hindi"
"040E"="hu;Hungarian"
"040F"="is;Icelandic"
"0421"="in;Indonesian"
"0410"="it;Italian (Italy)"
"0810"="it-ch;Italian (Switzerland)"
"0411"="ja;Japanese"
"0412"="ko;Korean"
"0426"="lv;Latvian"
"0427"="lt;Lithuanian"
"042F"="mk;FYRO Macedonian"
"043E"="ms;Malay (Malaysia)"
"043A"="mt;Maltese"
"0414"="no;Norwegian (Bokmal)"
"0814"="no;Norwegian (Nynorsk)"
"0415"="pl;Polish"
"0416"="pt-br;Portuguese (Brazil)"
"0816"="pt;Portuguese (Portugal)"
"0417"="rm;Rhaeto-Romanic"
"0418"="ro;Romanian"
"0818"="ro-mo;Romanian (Moldova)"
"0419"="ru;Russian"
"0819"="ru-mo;Russian (Moldova)"
"0C1A"="sr;Serbian (Cyrillic)"
"081A"="sr;Serbian (Latin)"
"041B"="sk;Slovak"
"0424"="sl;Slovenian"
"042E"="sb;Sorbian"
"040A"="es;Spanish (Traditional Sort)"
"080A"="es-mx;Spanish (Mexico)"
"0C0A"="es;Spanish (International Sort)"
"100A"="es-gt;Spanish (Guatemala)"
"140A"="es-cr;Spanish (Costa Rica)"
"180A"="es-pa;Spanish (Panama)"
"1C0A"="es-do;Spanish (Dominican Republic)"
"200A"="es-ve;Spanish (Venezuela)"
"240A"="es-co;Spanish (Colombia)"
"280A"="es-pe;Spanish (Peru)"
"2C0A"="es-ar;Spanish (Argentina)"
"300A"="es-ec;Spanish (Ecuador)"
"340A"="es-cl;Spanish (Chile)"
"380A"="es-uy;Spanish (Uruguay)"
"3C0A"="es-py;Spanish (Paraguay)"
"400A"="es-bo;Spanish (Bolivia)"
"440A"="es-sv;Spanish (El Salvador)"
"480A"="es-hn;Spanish (Honduras)"
"4C0A"="es-ni;Spanish (Nicaragua)"
"500A"="es-pr;Spanish (Puerto Rico)"
"0430"="sx;Sutu"
"041D"="sv;Swedish"
"081D"="sv-fi;Swedish (Finland)"
"041E"="th;Thai"
"0431"="ts;Tsonga"
"0432"="tn;Tswana"
"041F"="tr;Turkish"
"0422"="uk;Ukrainian"
"0420"="ur;Urdu"
"042A"="vi;Vietnamese"
"0434"="xh;Xhosa"
"043D"="ji;Yiddish"
"0435"="zu;Zulu"

Download a small archive with the following files:

km-040a.ini
km-040b.ini
km-040c.ini
km-041a.ini
km-041d.ini
km-041f.ini
km-042f.ini
km-080c.ini
km-0401.ini
km-0406.ini
km-0407.ini
km-0409.ini
km-0410.ini
km-0411.ini
km-0414.ini
km-0415.ini
km-0416.ini
km-0419.ini
km-0424.ini
km-0426.ini
km-0427.ini
km-0809.ini
km-0816.ini

xrdp.km-files.rar

Note: In recent Debian distros, filenames may have changed, so it may be necessary to rename km-0424.ini to km-00000424.ini

Enter your comment:
199 -6 = 
 
  • linux/misc/xrdp_hr_keymap.txt
  • Last modified: 2019/10/31 09:05
  • by 127.0.0.1