What's the easiest way to run GUI apps on Windows Subsystem for Linux as of 2018?

VcXsrv

I chose to use VcXsrv in WSL (Windows 10 Subsystem for Linux). I recommend everyone do their research between xming (the accepted answer) and VcXsrv before selecting one or the other for Graphical User Interface (GUI) support in Windows 10 Ubuntu 16.04.

Installation

Installation is straight forward. As of March 17, 2019 you can simply accept the defaults. If you want to call gedit from within your Bash Shell / Terminal you need to edit ~/.bashrc and insert this line:

export DISPLAY=localhost:0.0

What can you do after VcXsrv is installed?

I was able to run:

sudo apt install ubuntu-desktop
sudo apt install yad
sudo apt install gedit

... to install GUI desktop software. This then allowed me to run gedit and nautilus. Also I was then able to install specific GUI applications through the CLI (Command Line Interface) using apt or apt-get commands.

When I want to try many of my Ubuntu bash scripts within WSL VcXsrv must be installed so zenity and yad x-windows dialog boxes are displayed for user input.

As others have noted GUI within WSL is not perfect and you can expect to spend time problem-solving some issues. Also some GUI software simply won't work in WSL.

Setup notes

I modified /etc/environment to tweak GUI drop down menus:

PATH="/mnt/e/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
export LIBGL_ALWAYS_INDIRECT=Yes
export DISPLAY=localhost:0.0
  • /mnt/e/bin is unusual path because it is where I store scripts used in both Windows 10 dual boot WSL and Ubuntu 16.04 dual boot. Most users would not include this on their machine.

The short answer is you can not as WSL does not yet support this function. WSL is not a full Linux installation with a Linux kernel, it allows you to run some native linux commands / binaries on a Windows (Microsoft) kernel and has limitations.

See https://github.com/Microsoft/WSL/issues/2356

You can, however, install a 3rd party X server, such as xming, and ssh into your WSL.

https://virtualizationreview.com/articles/2017/02/08/graphical-programs-on-windows-subsystem-on-linux.aspx

I did not copy that tutorial here as it is fairly ubiquitous (X over ssh) and I would expect some apps simply will not work even with this technique.


I've had a very positive experience with VcXsrv on Win 10 Bash on Ubuntu on Windows (Ubuntu 16.04 Xenial x86_64 Linux 4.4.0-17074-Microsoft). I did not focus on running Unity desktop as it is useless and resource consuming. I just simply ran apps from bash in GUI mode from Windows10 desktop using XServer.

  1. Install VcXsrv from here on Sourceforge

  2. Run the VcXsrv app directly, do not launch XLaunch. You should see localhost:0.0 - 0 clients when you hover over the icon on Win10 Taskbar

  3. Open Ubuntu Bash:

     cd /mnt
    

(results in localhost@localhost:/mnt$)

    cd .. 

(localhost@localhost:/$ meaning this commands brings you to the beginning of the hard-drive as far as WSL can see...)

    sudo apt-get install dbus synaptic nautilus --install-suggests --show-progress

(this will install "dbus" to create virtual connector for GUI, "Synaptic Package Manager" and "Nautilus" file explorer for unity-desktop

    cd /usr/share/dbus-1 && sudo vi session.conf

(When session.conf opens in vi editor)

Press i to enter insert mode and add

    <!-- <listen>unix:tmpdir=/tmp</listen> || Original Command --> to preserve original rules

than add:

    <listen>tcp:host=localhost,bind=0.0.0.0,port=0</listen>
    <auth>EXTERNAL</auth>
    <auth>DBUS_COOKIE_SHA1</auth>
    <auth>allow_anonymous</auth> 

Press ESC when you are done editing file and :wq to save the file.

Run these commands and check their output:

    $ export DISPLAY=localhost:0
    $ sudo service dbus start
    * Starting system message bus dbus                 [OK]
    $ echo $DISPLAY
    localhost:0
  1. You are done! Now just run synaptic, nautilus or firefox from Bash and they should load on Win10 desktop. GUI options like this are buggy but operational. You can install ubuntu-desktop, unity, ccsm, compiz and try to run Unity Desktop for Ubuntu. I did not try to set the "Steam" because I am still suffering rrying to run "Unreal", Good luck :)

If someone knows how to run gnome-terminal on XServer instead of XTerm please share...

P.S
You can add VcXsrv as a Win10 bootable

To max your sources with "Steam" as specified in original post, tune your Windows a little for network package management (to lower latency) and CPU/GPU prioritization to make a Win10XBox… :)

Although you will run "Steam" under "Unix" the shell is still "Windows" which allows you to launch "Steam" on "Unix" …

Tcp Prep:;

In regedit:

 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters\Interfaces

Here you need to go through the list of sub-keys to locate the network adapter entry that is used to connect to the Internet. If you are using DHCP, you need to look for DhcpIPAdddress entry (with system data values NOT :0.0.0.0) to find the correct adapter.

Once you have located the correct key right-click it and select New > Dword (32-bit) Value.

Name it TcpFrequency and click ok.

Double-click the value afterwards and set its Decimal value to 1. (To restore the default setting, change the value to 2 or delete the key) Now navigate to the following key: HKEY_LOCAL_MACHINE\Software\Microsoft\MSMQ

Right-click on the key again and select New > Dword (32-bit) Value.

Name the new parameter TcpDelay

Double-click it afterwards and change its Decimal value to 1. (To restore the key at a later point in time change it to 0 or delete the key)

Nagle’s Algorithm

Nagle’s algorithm combines several small packets into a single, larger packet for more efficient transmissions. This is designed to improve throughput efficiency of data transmission. Disabling “nagling” can help reduce latency/ping in some games. Nagle’s algorithm is enabled in Windows by default. To implement this tweak, modify the following registry keys.

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{NIC-id}

For the {NIC-id}, look for the one with your IP address listed; under this {NIC-id} key create following DWORD value:

  • TcpFrequency and set it to 1 to disable “nagling” for gaming.
  • TCPDelay and set it also to 1 to disable “nagling”
  • TcpTicks and set it to 0

Note:

Some reports say that the tweaks did reduce latency when playing Dota 2 and League of Legends but it doesn’t work for some. I have tried it and my latency improved from 110 to 90ms (SEA Server) when playing Dota 2.

Network Throttling Index

Windows implements a network throttling mechanism, the idea behind such throttling is that processing of network packets can be a resource-intensive task. It is beneficial to turn off such throttling for achieving maximum throughput.

To implement this tweak, run regedit and modify the registry

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile. 

Under SystemProfile, create a DWORD value and name it to NetworkThrottlingIndex then set its Hexadecimal value to ffffffff for gaming and max throughput: ffffffff completely disables throttling.


System Gaming Responsiveness (Not so sure about this one :)

Multimedia streaming and some games that uses “Multimedia Class Scheduler” service (MMCSS) can only utilize up to 80% of the CPU. The “Multimedia Class Scheduler” service (MMCSS) ensures prioritized access to CPU resources, without denying CPU resources to lower-priority background applications.

To implement this tweak, run regedit and modify the registry key

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile. 

From there, create a new DWORD and name it to SystemResponsiveness set its decimal value to 00000000 for pure gaming/streaming.

In the same Registry hive as the above tweak, you can also change the priority of Games. To implement this tweak, go to

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks\Games

and change the following registry values:

  • “GPU Priority” change its values to 8 for gaming.
  • “Priority” set to 1 for gaming.

All cheers for "unknown" (pardon me was a while since I copied your directions) author of this Windows=Xbox tweak...

PPS: If XServer fails on what you would like to do try to find the workaround with Docker.

  • [WSL_Apache_Roolez][1]
  • [Throttling_a_'mm'_:0][2]
  • [You've Got Mail!!!][3]

Microsoft announced the green light for WSL 2 GUI: https://devblogs.microsoft.com/commandline/the-windows-subsystem-for-linux-build-2020-summary/#wsl-gui