Skip to content

Instantly share code, notes, and snippets.

@remlapmot
Last active March 21, 2021 23:52
Show Gist options
  • Save remlapmot/0e720b8bff25f1dbfd881b1c67f29e7f to your computer and use it in GitHub Desktop.
Save remlapmot/0e720b8bff25f1dbfd881b1c67f29e7f to your computer and use it in GitHub Desktop.
XLaunch file for running a windowed desktop environment for Ubuntu (or another Linux Distro) on WSL
<?xml version="1.0" encoding="UTF-8"?>
<XLaunch WindowMode="Windowed" ClientMode="NoClient" LocalClient="False" Display="-1" LocalProgram="xcalc" RemoteProgram="xterm" RemotePassword="" PrivateKey="" RemoteHost="" RemoteUser="" XDMCPHost="" XDMCPBroadcast="False" XDMCPIndirect="False" Clipboard="True" ClipboardPrimary="True" ExtraParams="-swcursor -ac" Wgl="True" DisableAC="False" XDMCPTerminate="False"/>
@remlapmot
Copy link
Author

remlapmot commented Mar 18, 2020

Tested with:

  • Ubuntu 18.04 on WSL 1 and 2:
    • mate-session
    • xfce4-session

@remlapmot
Copy link
Author

remlapmot commented Mar 25, 2020

  • Extra info from the Ubuntu wiki here
  • Download and install VcxSrv from here
    • Note this XLaunch config is simply the default settings with additional parameters -ac
  • Note: I have only tested this under Ubuntu 18.04.4 LTS (bionic).
  • Under WSL 1
    • As per instructions here in your ~/.bashrc set (edit this with vi with sudo vi ~/.bashrc)
      export DISPLAY=localhost:0.0
      
      Then re-read in .bashrc with source ~/.bashrc
  • Under WSL 2
    • As per instructions here in your ~/.bashrc set
      export DISPLAY=$(grep -m 1 nameserver /etc/resolv.conf | awk '{print $2}'):0.0
      
    • And if you have replaced the SSH server as per the instructions here
      # Remove the default install
      apt-get remove --purge openssh-server
      # Update
      apt-get update
      apt-get upgrade -y
      # Install OpenSSH Server
      apt-get install -y openssh-server
      
    • create /etc/ssh/sshd_config with the following settings.
      Port 222
      X11Forwarding yes
      X11DisplayOffset 10
      
  • Save in %appdata%\Microsoft\Windows\Start Menu\Programs\Startup to have this launched at login.
  • libGL error: If when you launch a graphical app from the Ubuntu Terminal you see an error as follows:
    libGL error: No matching fbConfigs or visuals found
    libGL error: failed to load driver: swrast
    
    this is fixed by installing Ubuntu MATE Desktop as per the advice here and here as follows.
    sudo su
    apt update && apt upgrade
    apt install ubuntu-mate-desktop --no-install-recommends
    dpkg-reconfigure dbus && service dbus restart
    
    sudo apt-get install mate-desktop-environment-extras
    
    # remove error report and some components: 
    apt remove apport *screensaver* update-notifier blueman
    
  • Launch a session with
    mate-session
    

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment