It's late, but I try to answer your questions anyway, for future reference.
How can I verify which keyboard layout is actually being used by xrdp?
setxkbmap -query
Where is this setting stored?
You can find keuborad settings in /etc/xrdp/xrdp_keyboard.ini: the file contains a mapping between languages and keyboard layouts hex number.
Is there a better way to get a working keyboard layout?
The easiest way in most cases is to use a workaround (please, note that you must performed these steps while you are directly logged in into the machine, not through the remote desktop connection):
Identify the hexadecimal number which corresponds to the desired layout by looking in the abov-mentioned file (xrdp_keyboard.ini).
Backup the default layout (US) used by xrdp:
sudo cp /etc/xrdp/km-00000409.ini /etc/xrdp/km-00000409.ini.bak
Generate the current layout keymap file assigning to it the name of the default one:
sudo xrdp-genkeymap /etc/xrdp/km-00000409.ini
Restart xrdp and try to log into the machine via remote desktop connection
sudo systemctl restart xrdp
Keep in mind that older versions of xrdp name the keymap files in a shorter way: km-0409.ini instead of km-00000409.ini.
To know what is going on, inspect xrdp logs:
tail -f /var/log/xrdp.log
UPDATE: nevertheless, you might experience again the same problem when reconecting a second time to the same host: it's a known issue. I don't know how to resolve it, but please, consider also the language settings on the Control Panel of the Windows client (or whatever is your client).
Someone in the aforementioned issued suggested to modify the source code to mitigate the problem experienced when reconnecting:
- modify function rdpLoadLayout (change default options of layout and comment code when it mast be reapply with client info options):
static int
rdpLoadLayout(rdpKeyboard *keyboard, struct xrdp_client_info *client_info)
{
XkbRMLVOSet set;
int keylayout = client_info->keylayout;
LLOGLN(0, ("rdpLoadLayout: keylayout 0x%8.8x variant %s display %s", keylayout, client_info->variant, display));
memset(&set, 0, sizeof(set));
set.rules = "base";
set.model = "pc105";
set.layout = "us,ru";
set.variant = "";
set.options = "grp:ctrl_shift_toggle";
reload_xkb(keyboard->device, &set);
reload_xkb(inputInfo.keyboard, &set);
return 0;
}
- modify function rdpkeybControl
set.model = "pc105";
set.layout = "us,ru";
set.variant = "";
set.options = "grp:ctrl_shift_toggle";