Today, we are back with a short post about XRDP and Unity Desktop in Ubuntu 17.04. Installing xrdp in Ubuntu 17.04 is really easy and there is no major configuration changes that’s needed in order to have it working. However, there is one small limitation that kind of annoying if you are not a technical user. This limitation is the fact that the Unity Desktop is not loading automatically when performing your remote desktop connection. The user will need to start the Unity Desktop inside the remote desktop session….and this is not cool….
In this post, we will provide a possible strategy that can be used in order to have the Unity Desktop loaded automatically when the user connect to the Ubuntu machine through remote Desktop session.
Let’s do this…..
In one of our previous post, we have demonstrated how to install xrdp package software on a Ubuntu 17.04 machine. The process is quite straightforward nowadays. Nowadays, you simply needs to install the xrdp package from Ubuntu repository in order to have a working remote desktop solution. The xrdp package shipped with Ubuntu 17.04 is the version 0.9.1.xx which offers out of the box drive redirection and clipboard capabilities. It also offer the new xorgxrdp backend component aimed to replace the vnc server that was used in previous versions…
A lot of improvements have been made in the latest iteration of xrdp package and Ubuntu latest release. It now easier to install and use xrdp software against Linux machine. However, there are still some small issues that exist. One of them is when you are using Unity Desktop Interface in Ubuntu 17.04.
In the post XRDP – How to install XRDP on Ubuntu 17.04 – Easy Way, one of the limitation or drawback of using Unity and xrdp was that the Unity Desktop interface needed to be started manually. In other words, the first time you connect to your Ubuntu machine using xRDP, you will get a black screen. If you right click on the black screen and start the terminal session, you will be able to issue the necessary command to start Unity…. These actions will load the Unity Desktop at the end but we have been looking for better ways to perform the same actions in an automated way….
The Old Way
In previous versions of xrdp and/or Ubuntu, we could use the file .xsession or /etc/xrdp/startwm.sh to have the desktop interface loaded automatically. In Ubuntu 17.04, it’s not the case anymore. In our case, each time we have populated the .xsession file with the Unity desktop instructions, a remote connection was performed which was immediately dropped….
So, this approach seems to be broken in Ubuntu 17.04 (with Unity Desktop)
We needed to came up with another solution…..
The Alternate Way
In the post XRDP – How to install XRDP on Ubuntu 17.04 – Easy Way, a workaround has been mentioned in order to load automatically the Unity Desktop. The alternate way is basically a way to execute a script at startup when the user logs in. Luckily for us, Ubuntu ships with a small tool that can done exactly that. The name of the tool is Startup Applications.
If you are logged locally on your Ubuntu machine, launch the Dash and type the following Startup Applications. You should see the following icon. Click on it
Click on picture for better resolution
If everything is OK, you should see the startup application windows displayed in front of you. You have now the possibility to add the application (or script) you would like to have loaded when the user logs in…. Press Add button and provide the requested information.
Click on picture for better resolution
The most important part here is the command textbox. In this textbox, you will need to specify the script you would like to have started at startup.
The Script to load Unity Automatically 🙂
It’s time for us to share an extract of our startup script that we used to load automatically the Unity Desktop. The script provided is really basic but should provide the necessary actions needed to have Unity loaded automatically.
Initially, we thought that creating a startup-unity.sh file, make it executable and populating with the simple command like
would have been enough…. but this is not enough….we could do better.
What we need to do in our script is to simply detect the Display we are connected to. if the Display is :0 we are logged on locally. However, if the display is :10 then, we are probably using the Remote Desktop Connection.
So, the following commands could be used
## Get the display value for the session... test=$(echo $DISPLAY) if [ $test = ":10.0" ] then ## Connected through Remote Desktop so load Unity Desktop exec unity else ## Do not execute anything this is local connection fi
The script above assume that basically only one user would connect to the remote session and the display that will be used would be :10. However, in real life, this is not necessarily the case. If you have more users or that for any other reasons the display number has changed from :10 to :11 or :12….the startup script is not working anymore….
So, the workaround would be to look for something that’s different that :0 instead of looking of specifically for display :10. So, a possible better script would be to perform a check like this
## Get the display value for the session... test=$(echo $DISPLAY) if [ $test != ":0" ] then ## Connected through Remote Desktop so load Unity Desktop exec unity else ## Do not execute anything this might be local connection fi
This script should cover most of the scenarios…..
And voila ! Now, using this alternate approach you should be able to have Unity Desktop loaded automatically while performing your remote desktop connection through xrdp package. Between each releases of Ubuntu and xrdp, it seems that improvements are made available. On the other hands, some of the features breaks between releases… This is becoming frustrating…..
So, yes it’s possible to use xrdp against Ubuntu 17.04 but you still need to create a startup script to have the Unity Desktop loaded automatically. In the past, we could use the .xsession file or the /etc/xrdp/startwm.sh. These approaches does not seems to work anymore. We had to come up with an new way of doing things. The startup script seems to be a pretty good approach…Using this approach and performing a standard xrdp installation process (while taking into account all the limitations of the solutions), you should be able to remote desktop directly into your Unity Desktop via remote sessions…
Hope this post can be useful to anybody…
Till next time…