Hello everybody !
I recently discovered WSL on my new laptop and now love to use it. I am using Xubuntu (Xfce) and xrdp to get an Ubuntu desktop environnement (see this simple tutorial
The only unpleasant thing with this solution is that every times you want to use your linux desktop you have to do few steps :
- launch xrdp services with sudo on Ubuntu
- enter your root password
- launch Remote Desktop Connection on Windows with the appropriate computer adress
Ok, it's not a lots of steps but it's a bit annoying to do this every times. So I did some scripts to automatise this process (as shown in the pictures bellow) and I want to share my solution. I'm not a system expert, so my solution may not be the best, but it works well anyway.
Launch xubuntu desktop button
If you want to implement this launch button, just follow this tutorial (sorry if bad english, i'm not a native english speaker) :
First of all, I assume that you already have a working Xfce environnement on Ubuntu on Windows and that you use the Remote Desktop Connection. If not, you can just see the tutorial in the link I gave at the begining of this post. In this tutorial you will have to create several scripts. You can obviously save the scripts in differents folder or with different name than mine, but then don't forget to changes all the paths given in the scripts. Obvious tutorial instruction : each occurence of "YourUserName" have to be replace by your own user name.
STEP 1 : LINUX XRDP SCRIPT
On your linux environnement, create a new script, type in your terminal :
then, enter :
##Launch server sudo sed -i 's/port=3389/port=3390/g' /etc/xrdp/xrdp.ini sudo service xrdp restart #start or restart xrdp session
Save it with ctrl+x and enter.
Gave to this script excution right, type in your terminal :
chmod +x ~/.Server_Xfce.sh
Server_Xfce.sh is a safe script that launch the xrdp session but that need password to run, we don't want this. So type in your terminal :
enter your root password, then add this line using your own username to the file and save it.
YourUserName ALL = NOPASSWD: /home/YourUserName/.Server_Xfce.sh
For me, this file look like this :
# # This file MUST be edited with the 'visudo' command as root. # # Please consider adding local content in /etc/sudoers.d/ instead of # directly modifying this file. # # See the man page for details on how to write a sudoers file. # Defaults env_reset Defaults mail_badpass Defaults secure_path="/uslocal/sbin:/uslocal/bin:/ussbin:/usbin:/sbin:/bin:/snap/bin" # Host alias specification # User alias specification # Cmnd alias specification # User privilege specification root ALL=(ALL:ALL) ALL # Members of the admin group may gain root privileges %admin ALL=(ALL) ALL # Allow members of group sudo to execute any command %sudo ALL=(ALL:ALL) ALL azerus ALL = NOPASSWD: /home/azerus/.Server_Xfce.sh # See sudoers(5) for more information on "#include" directives: #includedir /etc/sudoers.d
STEP 2 CREATE SCRIPTS TO EASILY SHARE INFORMATION BETWEEN LINUX AND WINDOWS
(I think it's possible to do this step differently using instead environnement variable shared between windows and linux, if you are brave enought to try.)
Always in your linux environnement, type in your terminal :
mkdir ~/.Winbuntu_va nano ~/.Winbuntu_va.winbuntuVar.pipe
then, enter :
and save it.
let's create a new script, type in your terminal :
Write in it, with your own user name :
sed -nr "/^\s*$1\s+.*$/p" /home/YourUserName/.Winbuntu_va.winbuntuVar.pipe | cut -d ' ' -f2
and save it.
let's create an other script in linux, type in your terminal :
write in it, with your own user name :
if [ $# -eq 1 ]; then sed -ri "/^\s*$1\s+.*$/d" /home/YourUserName/.Winbuntu_va.winbuntuVar.pipe else if [ "$(/home/YourUserName/.getWinbuntu.sh $1)" = "" ]; then echo $1' '$2 >> /home/YourUserName/.Winbuntu_va.winbuntuVar.pipe else sed -ri "s/^$1 .*$/$1 $2/g" /home/YourUserName/.Winbuntu_va.winbuntuVar.pipe fi fi
and save it.
lastly, we have to give this scripts excution right, enter in your terminal :
chmod +x ~/.getWinbuntu.sh chmod +x ~/.setWinbuntu.sh
STEP 3 CHANGE .BASHRC FILE
Open your bashrc file, type in your terminal :
and add the end of this file, with your own user name :
##Launch server xrdp if needed if [ "$(/home/YourUserName/.getWinbuntu.sh LaunchServer)" = 1 ]; then echo Launching xrdp server ... sudo /home/YourUserName/.Server_Xfce.sh /home/YourUserName/.setWinbuntu.sh LaunchServer 0 fi
You can close the terminal, we're done with linux scripting.
STEP 4 FINAL : WINDOWS SCRIPT
Start by creating a folder in your Windows environnement. You can create it anywhere you want, keep in mind that you won't be able to move it or rename it afterwards (or you'll have to update some paths). I'll refer to this folder as "launcherFolder" in the nexts steps.
Launch mstsc.exe and show options.
Enter 127.0.0.1:3390 in the computer field.
Put the display cursor to fullscreen.
Save your connection parameters in launcherFolder with the name : "connection_setting.rdp"
Do not start the connection, just close mstsc.
Write in it, with your own launcherFolder path and your own user name :
::Tell Ubuntu to launch xrdp ubuntu run /home/YourUserName/.setWinbuntu.sh LaunchServer 1 start ubuntu ::temporize executions :TEMPO timeout /t 2 for /f %%i in ('ubuntu run /home/YourUserName/.getWinbuntu.sh LaunchServer') do set xrdpReady = %%i if "%xrdpReady%" == "1" goto TEMPO ::Connect to the desktop start mstsc "launcherFolderPath\connection_setting.rdp
And save it as Ubuntu_Desktop_Connection.bat in launcherFolder
Create a shortcut to this bat file.
You can change the icon of the shortcut and rename it.
If you did everything right, you should be able to launch your Ubuntu desktop with this short cut.
OPTIONAL STEP : Pin the shortcut to the start menu
Move your shortcut to "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories"
Then, search for your shortcut in the taskbar using the name you gave to it.
(Yes, my desktop wallpaper change automatically)
Right click on it and pin it ! (see the first picture of this post to see the result)
FREE ADDITIONAL TIP
One good thing with windows 10 is that you can have multiple desktop and use it to change quickly between Windows and Ubuntu. But the key combinations (like windows+ctrl+left or right) are not send to Windows.
I know 2 solutions :
Solution 1 :
If you have a multitouch touchpad you can switch between windows desktops by slidding with 4 fingers !
Switching between Windows and Ubuntu (yes i like to show my different wallpapers)
Or solution 2 :
See the autohotkay solution there : https://superuser.com/questions/1046767/windows-10-switch-virtual-deskop-while-in-fullscreen-remote-desktop
I hope this tutorial will help some of you !
Feel free to ask question, propose others solutions, adapt the solution for other distributions, or comment.