Ubuntu: Run a command at the start of XRDP session


Update actually /etc/xrdp/reconnectwm.sh does get executed at reconnect but the setxkbmap options do not "take".


I'm using single board computer(s) over (x)rdp. This is all working okay EXCEPT I cannot make setxkbmap run when reconnecting to xrdp session.

There are various configuration files which seem to be executed at startup. .profile is executed for login shell and sticking the setxkbmap there gives you UK/Finnish keyboard when you first start a shell.

But when you close your remote desktop and reconnect later, it's back to US keyboard. I know I could overwrite the US keyboard file in /etc/xrdp but that's not very elegant solution plus I lose the ability to switch between keyboards with shift-alt.

For those interested, I have the lines

setxkbmap -layout "gb,se"  setxkbmap -option "grp:alt_shift_toggle"  

in .profile and .bashrc. So after reconnecting I can open a terminal and it restores the keyboard..

Surely there must be a script that is executed when remote connection is re-established? there's reconnectwm.sh in /etc/xrdp but it won't work of course.


Having the same problem, solved by adding in /etc/xrdp/reconnectwm.sh " sleep 2s " before " setxkbmap " command.

Wrong way, but it works.


It may be worth trying to set the values system wide by editing /etc/default/keyboard:

XKBLAYOUT=gb,se  XKBOPTIONS=grp:alt_shift_toggle  

Should be effective after next reboot.

With that you should be able to drop the setxkbmap calls in ~/.profile and ~/.bashrc.


I figured out a way to make this happen.

If I source another script from the reconnectwm.sh that contains the the setxkbmap commands, it will stick.

Weird, but hey, it works!

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »