How to install Xfce4 on Ubuntu 18.04 WSL

1 minute read

Installing xfce4 on WSL

Amazingly, you can run a Window environment with WSL. This lets you run nix based GUI applications on Windows. Not officially supported, but I personally haven’t had any issues.

I am running this on Ubuntu 18.04


First off update your system and install xfce4

$ sudo apt update && sudo apt install xfce4 -y

Next on Windows go ahead download and install VcXsrv

Next you need to set the default display in WSL, so in your bash prompt set it as follows:

$ export DISPLAY=:0.0

If you would like to make the change permanent, add that line to the end of your .bashrc

That’s it! Installation is complete.


Now lets get VcXsrv up and running. Run VcXsrv and then select the One Window without titlebar option

Select One Window Without Titlebar

Next select Start no client

Select Start no Client

Now select Disable Access Control

Select Disable Access Control

Finally you can save the configuration and Finish up

Save Configuration

You should have a blank VcXsrv screen now open. Open up your bash prompt and type:

$ xfce4-session &

Your Desktop should now show up on in the VcXsrv window.

Bonus: Automation

To automate the entire process if you like, you can create a VBS script that will automatically run VcSrv with the correct configuration and then launch and xfce4-session as follows.

Create a new bash script called as follows:

# This script checks if another xfce4-session is running first.
if [ -z $(pidof xfce4-session) ]; then
    source ~/.bashrc


Ensure the script is executable via chmod +x

Next on the windows side create a new VBS Script wslgui.vbs and then add the following code. Obviously update the install and script locations to wherever they are for you

' Script to Automatically Run and Xfce4 Session
' It opens a single window/no-decoration VcXsrv window
' Then runs your WSL Launch Script
' Update file locations accordingly

Set shell = CreateObject("WScript.Shell" )
shell.Run """C:\Program Files\VcXsrv\vcxsrv.exe"" :0 -screen 0 @1 -nodecoration -wgl"
shell.Run "bash -c ""~/""", 0

Now Run the Script and you should automatically get a running desktop environment.

From here you can go ahead and try a few themes and other customisations to get working.