Running Linux GUI applications on Windows

Published: February 22, 2021   |   Read time:

Tagged:

Different people use different operating systems throught their work and personal lives. There are a lot of reasons why, but the effect of this is that almost every person who has a computer uses multiple operating systems. iOS and macOS are different, Windows and Android are different, and flavours of Linux are different from each other. This often creates situations where people want to use a certain piece of software, but it’s not available on their operating system, so they have to find something else.

This happens a lot with Windows, since Windows is the operating system outcast compared to Linux and macOS. But Windows has been trying to bridge this gap over the years with its introduction of its Windows Subsystem for Linux (aka WSL). This allows users to install Linux operating systems on their Windows machine and run programs more efficiently than a virtual machine would allow. Ubuntu, Kali, Fedora, and many of Linux distributions are easily installable via this subsystem, making it easier to compile and run Linux programs 1.

Users can interact with Linux programs via the command line, but this still leaves Linux-based graphical user interface (GUI) applications off the table. There are many great Linux GUI applications that aren’t available on Windows, like Evolution, Evince, and KdenLive. But because they’re GUI based, not just available through the command line, it’s not straightforward to get these to run on Windows through WSL.

This post is a walkthrough of how to get these Linux GUI applications running on Windows.

What we need

There are two main components we need.

  1. WSL
  2. VcXsrv

I won’t list the install instructions here, you can refer to those links for details.

The main idea here is to tell the Linux subsystem to send its GUI elements not to the standard desktop that would come with the Linux OS, but to a different server that is being run on Windows. VcXsrv is the Windows application that provides this server and can display GUI elements. It will act as a bridge between the Linux subsystem and the Windows graphics drivers to display the Linux GUI on the Windows desktop.

Configuring VcXsrv

Once VcXsrv is installed, we can configure it to handle the Linux applications that will be displayed. On Windows, go to Start Menu > XLaunch, and enable both public and private network access in the Windows Firewall popup. This will launch the configuration settings for the X Server.

XLaunch config 1 -80%

Select “Multiple windows”. On the next screen, select “Start no client”.

XLaunch config 2 -80%

On the next screen, check all 3 boxes, including “Disable access control”.

XLaunch config 3 -80%

We can save this configuration to make it easier to launch X Server in the future. Once you’ve done this, click “Finish” to start the server.

XLaunch config 4 -80%

No new applications will appear, but you should see the XLaunch icon in the notification tray once it starts.

XLaunch config 4 -40%

Configuring WSL

The only step that is necessary is to have the DISPLAY environment variable set to the right value to connect to the X Server. In your Linux distribution, edit ~/.bashrc (or ~/.bash_profile, or whatever environment config file is used for your shell) and add the following line to it.

export DISPLAY=127.0.0.1:0.0

This ensures that when the Linux session starts, it knows to send all GUI elements to this address, which is the address that the X Server running on Windows is providing. Restart your Linux session and test that DISPLAY is set properly by running

echo $DISPLAY

Testing out Linux GUI apps

We’re going to test out Firefox as an example. Install it in your Linux subsystem with its package manager. In Ubuntu, the command is sudo apt install firefox.

Once installed, ensure that VcXsrv is running on Windows, then run firefox from the Linux command line. If everything is working properly, a Firefox window should open on your desktop.

Firefox -100%

You can see thw two different versions of Firefox running at the same time. The one on the left is the Firefox installed natively on Windows, and the one on the right is installed in my Ubuntu subsystem. You can also see the fonts are different, the header title bar is explicit on the Ubuntu version instead of being integrated with the tab bar in the Windows version, and there are some other minor graphical differences. But this is an entirely separate Firefox running under the hood.

Conclusions

This is a great stepping stone for getting Linux GUI applications to run on Windows, and brings the operating systems closer together for users. There are definitely differences in quality for some Linux applications, like missing icons or errors rendering certain fonts. There are also major drawbacks, such as integrating with other applications. Clicking a link in an email in Evolution on Linux can’t open my Firefox browser installed on Windows, for example. But at least this provides some method to run Linux GUI applications on Windows when needed.

The setup process isn’t too difficult, but it’s definitely not trivial if you don’t know what you’re doing. But with these few steps, feel free to try out your favourite Linux app on Windows.

Footnotes

  1. As a computational biologist, this makes it much easier to work on a Windows machine. Many libraries and tools are developed to work in Linux and don’t work in Windows. Without the WSL, working from home on a Windows machine during a global pandemic would be much harder.