Running WSL GUI Apps on Windows 10
Published Jun 27 2020 09:12 AM 503K Views
Microsoft

logo.png

 

 

 

In this post I will demonstrate how to run Linux GUI (Graphical User Interface) applications on Windows Desktop platform.

 

For now, it is necessary to install a third-party App to run the GUI Apps, but Microsoft announced on //build 2020 that they will release soon an improvement that will not require any third-party component to run Linux GUI Apps on Windows Desktop.

 

Pre-requirements:

  • Windows 10
  • WSL

 

If you want to know how to install WSL on Windows 10, please check the following post:

 

 

logo.pngUsing WSL2 in a Docker Linux container on Windows to run a Minecraft Java Server

 

 

It will be demonstrated the three ways to run the Linux GUI Apps on Windows 10 through:

  • VcXsrv Windows X Server (free)
  • X410 App available on Microsoft Store (paid app)
  • Kali App available on Microsoft Store (free)

 

First option: VcXsrv Windows X Server

The X server is a provider of graphics resources and keyboard/mouse events. I am using the VcXsrv Windows X Server that is open-source and is frequently update.

 

The first step is to install the third-part display manager called VcXsrv Windows X Server available at:

https://sourceforge.net/projects/vcxsrv/

 

During setup is important to disable the access control to avoid the permission denied error when trying to run a GUI application:

 

VcXsrv disable access control 2.png

 

 

To warranty that the “Disable access control” will be always checked, save the configuration and always launch VcXsrv using the configuration file (config.xlaunch) :

 

VcXsrv disable access control.png

 

 

NOTE: Don't forget to allow VcXsrv in the Windows firewall settings.

 

Windows Security -> Firewall & network protection -> Allow an app through firewall -> make sure VcXsrv has both public and private checked.

 

firewall.png

 

 

The next step is to set the DISPLAY environment variable on Linux to use the Windows host's IP address as WSL2 and the Windows host are not in the same network device. It is necessary to set the DISPLAY environment variable with the correct IP address on launch. There are different ways to set the DISPLAY variable, thank you @ZeevS and @Barry_Bazza for the updates.

 

Follows some ways that you can choose:

 

export DISPLAY="`grep nameserver /etc/resolv.conf | sed 's/nameserver //'`:0"

export DISPLAY="`sed -n 's/nameserver //p' /etc/resolv.conf`:0"

export DISPLAY=$(ip route|awk '/^default/{print $3}'):0.0

 

 

Running the following command, it is possible to see that the $DISPLAY environment variable now has the Windows Host’s IP set:

 

 

Echo $DISPLAY

 

 

display.png

 

 

To avoid having to run that command every time that WSL is launched, you can include the command at the end of the /etc/bash.bashrc file:

 

export display.png

 

 

UPDATE: I would like to thank @samuel_skeen for let me know that now it is also necessary to create a .xsession file in the user's home directory (/home/<user>/.xsession) with the content xfce4-session:

 

 

echo xfce4-session > ~/.xsession

 

 

Done! Now you can run the Linux GUI Apps on Windows desktop.

 

Let’s try this out!

 

Follows some Apps that you can use to test:

 

Install Chromium Dev :

 

sudo add-apt-repository ppa:saiarcot895/chromium-dev
sudo apt-get update
sudo apt-get install chromium-browser

 

 

Install GEDIT:

 

sudo apt install gedit
gedit

 

 

Install x11-apps:

 

sudo apt install x11-apps
xeyes
xcalc

 

 

 

Make sure that XLaunch is running and before calling the Linux GUI Apps on Windows Desktop environment.

 

apps running.png

 

run gui apps wsl.gif

 

 

What about running Windows 10 Apps and Linux GUI Apps in the same Desktop?

 

Run the following command to launch the xfce-panel:

 

xfsettingsd --sm-client-disable; xfce4-panel --sm-client-disable --disable-wm-check &

 

 

 

What about accessing the Linux Desktop Environment via RDP?

 

The first thing that you need to do is to install a Linux Desktop Environment. I will user Xfce as it is a lightweight one.

 

Run the following commands to install Xfce:

 

sudo apt install xfce4

 

 

The next step is to install the xrdp that provides a graphical login to remote machines using RDP (Microsoft Remote Desktop Protocol).

 

sudo apt install xrdp

 

 

Type the following command to get the WSL IP address:

 

ip a

 

 

ip addr.png

 

Make sure that xrdp service is running:

 

start xrdp.png

 

Run the Remote Desktop Client (MSTSC) and type the WSL IP address to connect to xfce4:

 

mstsc.png

 

 

 

Done! Now you can access your favorite Linux IDE on WSL.

 

 

wsl rdp.png

 

wsl rdp 3.gif

 

 

Second option: X410 App

The app is available on Microsoft Store:

https://www.microsoft.com/store/productId/9NLP712ZMN9Q

 

X410.png

 

In the image below I am using the the X Server X410 App available in the Windows 10 store, that has a better graphic performance:

 

WinLinux.gif

 

 

Enabling Sound

X410 X Server App, as well as XLaunch, supports sound on Ubuntu (18;04 and 20.04). If you are using X410, please following the steps available at:

 

https://x410.dev/cookbook/wsl/enabling-sound-in-wsl-ubuntu-let-it-sing/

 

I only had to change the third step to use auth-anonymous instead of the auth-ip-acl:

load-module module-native-protocol-tcp auth-anonymous=1

 

More details here: https://github.com/microsoft/WSL/issues/4205

 

I defined the PULSE_SERVER environment variable too, as:

 

export PULSE_SERVER=tcp:$(grep nameserver /etc/resolv.conf | awk '{print $2}')

 

 

Thank you @Barry_Bazza, for letting me know that the following Pulse Audio version also works: pulseaudio-5.0-rev 18 .

 

This is the code bat file that I am using to load X410:

 

@echo off
start /B x410.exe /wm
start "" /B "C:\wsl\pulseaudio\bin\pulseaudio.exe"

ubuntu2004.exe run "if [ -z $(pidof xfce4-panel) ]; then export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}'):0;export PULSE_SERVER=tcp:$(grep nameserver /etc/resolv.conf | awk '{print $2}'):0;  cd ~; xfsettingsd --sm-client-disable; xfce4-panel --sm-client-disable --disable-wm-check; taskkill.exe /IM x410.exe;taskkill.exe /IM pulseaudio.exe /F; fi;"

 

 

For more details about how to enable the xfce-panel steps, please check:

https://x410.dev/cookbook/wsl/xidekick/ 

 

Follows a great thread about how to fix sound issues:

 

No sound in wsl2 · Issue #4205 · microsoft/WSL (github.com)

 

Third option: Kali App

Kali Linux Windows Application is available on Microsoft Store:

https://www.microsoft.com/store/productId/9PKR34TNCV07

 

Once installed, after having providing the credentials, run the following command to install Win-KeX to allow running GUI Linux Apps on KALI for Windows:

 

sudo apt update && sudo apt install kali-win-kex

 

 

Run the following command to run Kali:

 

kex wstart

 

 

 

kex wstart.png

 

The KALI environment will be loaded:

 

kali.png

 

With Kali, you don't have to worry about setting environment variables or starting services.

 

Follows the Kali page with more details:

Kali Linux in the Windows App Store | Kali Linux

Win-KeX Version 2.0 | Kali Linux

 

In this post we see how to run GUI Linux Apps using XServer on Windows Desktop environment and how to access the full WSL Linux desktop environment.

 

I hope you liked!

 

 

129 Comments
Version history
Last update:
‎Jan 15 2021 03:49 PM
Updated by: