Preface: I Need the Latest xrdp
During the holidays the keyboard of my laptop started to indicate that there is no eternity in the world. And especially not among the cheapo laptops. Since a new laptop with a decent screen and processor would const a fortune, I decided to try another approach. Why don’t I install a desktop Linux to my Xen server and use it for daily tasks? In this setup the laptop wouldn’t need to have a capable processor.
I wanted a setup where the connection would be direct without any servers between. I don’t want anyone to follow my mediocre node.js stumbles or follow my bank sessions. TeamViewer and similar helpdesk tools are no-go.
I did some testing with NoMachine NX, but it felt a bit clumsy although the setup was painless. Using X was not sufficient option since you want to hear the sounds when watching YLE Areena, right?
Finally I ended up working with xrdp, a Linux realisation of Microsoft’s Remote Desktop Protocol. The protocol supports sound and its performance should be enough for multimedia. Well, it quickly turned out that the pre-packaged version of xrdp (the server) did not have support for sound. It didn’t support mouse wheel either which is another “must”. Thus I needed to compile the latest version myself.
The Beef: Compiling xrdp With Sound
Get the source from xrdp site. My version was 0.9.4. First compile xrdp. Make sure you have build-essential installed and give it a try:
cd xorg/ ./configure make sudo make install
Compiling X11 with RDP support
It turns out that the pre-packaged Xorg does not have RDP support and we need to compile X11 with RDP support as well:
apt-get install xsltproc flex bison libxml2-dev python-libxml2 cd xorg/X11R7.6/ ./buildx default
Install (copy) the binary to /usr/local/bin as root:
cp rdp/X11rdp /usr/local/bin
Now start (again, as root):
By default xrdp server supports multiple session types. Since I want to provide the RDP protocol only I have to edit /etc/xrdp/xrdp.ini. The session types are in the bottom (after [Channels] section).
Leave only X11rdp connection type:
[X11rdp] name=X11rdp lib=libxup.so username=ask password=ask ip=127.0.0.1 port=-1 xserverbpp=24 code=10
Getting sound to work
Building Pulseaudio sound modules requires a bit extra work.
First, get the version of your Pulseaudio installation:
$ pulseaudio --version pulseaudio 8.0
Get the pulseaudio source and unpack it somewhere. I used ~/src/pulseaudio and now I have ~/src/pulseaudio/pulseaudio-8.0. Now go to forementioned directory and compile your Pulseaudio:
apt-get install intltool libjson-c-dev libsndfile1-dev ./configure --without-caps make
Now back to xrdp:
Edit PULSE_DIR (in xrdp/sesman/chansrv/pulse/Makefile) to point to the path you have your Pulseaudio source. In my example:
PULSE_DIR = /home/matti/src/pulseaudio/pulseaudio-8.0
Now you have module-xrdp-sink.so and module-xrdp-source.so. Copy them to Pulseaudio libs (as root)
cp *.so /usr/lib/pulse-8.0/modules/
Add following lines to your /etc/pulse/default.pa:
load-module module-xrdp-sink load-module module-xrdp-source set-default-sink xrdp-sink set-default-source xrdp-source
Note! In my case pavucontrol crashed the RDP connection for whatever reason. If you encounter problems you can list sinks and sources with these commands:
$ pacmd list-sinks | grep -e 'name:' -e 'index' * index: 1 name: <xrdp-sink> $ pacmd list-sources | grep -e 'name:' -e 'index' index: 1 name: <xrdp-sink.monitor> * index: 2 name: <xrdp-source>
You can restart the xrdp server by restarting xrdp and xrdp-sesman.
At this point your Linux desktop can be connected using Windows Remote Desktop Client. Since none of the pre-packaged rdp clients did not work, had lag or did not support sound i decided to build latest FreeRDP. I personally decided latest nightly build offered from their CI at https://ci.freerdp.com/job/freerdp-nightly-binaries/.
To open a connection I enter:
/opt/freerdp-nightly/bin/xfreerdp /kbd:0x0000041D /sound /v:[MY SERVER NAME]
The /kbd value uses Swedish keyboard layout. You can get the possible values by entering:
You don’t need to edit the keyboard settings in the target machine. Actually editing them made FreeRDP to segfault.
Epilogue: Was it Worth it?
The original goal was to use the remote desktop as a workstation for daily use: browsing the Net, reading emails and doing some garage programming. Was this setup good enough for this?
There is slight lag with the display: when you close a window it can take 1-2 seconds before the screen updates. Changing the virtual desktop is sluggish. The mouse roller is inaccurate. I used this for one or two days and then destroyed the whole thing.