Software Development in Linux-WSL and GUI

Mostafa Farrag
Hydroinformatics
Published in
7 min readAug 27, 2023

--

Using a Graphical User Interface (GUI) within the Windows Subsystem for Linux (WSL) can greatly enhance the user experience and productivity for those who are accustomed to graphical interfaces. While WSL primarily offers a command-line interface, integrating a GUI environment can make it easier to interact with Linux applications and tools that rely on visual interfaces. One popular solution for enabling GUI applications in WSL is through the use of Xming, a versatile X Server implementation for Windows.

Xming provides the capability to display Linux GUI applications on the Windows desktop, effectively bridging the gap between the two operating systems. This integration allows users to run graphical Linux applications side by side with their Windows applications, providing a seamless and integrated experience.

For beginners, navigating and operating solely within the terminal environment of WSL might pose challenges. While the command line offers powerful capabilities for experienced users, those new to Linux or programming might find it intimidating. Command-line interfaces often require familiarity with various commands and syntax, which can be overwhelming for beginners. Furthermore, certain tasks, especially those involving complex graphical applications, can be more intuitive and efficient when presented through a GUI.

In such cases, utilizing Xming to enable GUI support in WSL can significantly ease the learning curve and enhance usability. It allows beginners to interact with Linux software in a more familiar manner, reducing the need to memorize intricate command sequences. Instead of grappling with terminal commands, users can leverage graphical interfaces that present information and options visually, making it easier to grasp concepts and perform tasks.

In this guide, we’ll explore the process of setting up Xming with WSL to enable GUI support, thereby bridging the gap between the command line and a graphical environment.

In the beginning, we have to explain how the GUI works in Linux.

Graphical Interface in Linux

Display manager (Xserver)

The X Window System, commonly referred to as “X11” or simply “X”, is a computer software system and network protocol that provides a graphical user interface (GUI) and input device capabilities for networked and local computing.

The central component of the X Window System is the X server. The X server is responsible for managing graphical output, handling input from devices like keyboards and mice, and coordinating the interaction between applications and the display hardware. It serves as a mediator between the user interfaces of different programs and the display hardware itself. X Server acts as a communication link between applications (clients) and the display hardware.

The X server is responsible for tasks such as:

  • Managing windows and their placement on the screen.
  • Rendering graphics and text.
  • Handling input events like mouse clicks and keyboard input.
  • Communicating with hardware drivers to display graphics on the monitor.
  • Providing the infrastructure for GUI toolkits and window managers to function.

X Server is responsible for creating a graphical environment in which desktop environments like GNOME and other graphical applications can run.

It’s important to note that while X11 has been a foundational technology for graphical interfaces on Unix-like systems, newer display systems like Wayland have been developed to address some of the limitations and complexities of X11. Wayland aims to provide a more modern and efficient framework for graphics display and interaction.

Xming

  • Xming is a specific implementation of an X server that is designed to run on Microsoft Windows operating systems.
  • Xming allows Windows systems to act as X servers, enabling them to display graphical output from remote Unix-like systems running X client applications.
  • Xming is essentially an X server for Windows that facilitates the integration of X client applications with the Windows desktop environment.
  • There are other Xserver implementations like VcXsrv, with minor differences.

Window managers (GNOME)

Window manager controls

  • The exact placement and appearance of windows in the graphical interface.
  • Control pointer focus properties.
  • Handling multiple desktops.
  • Providing tabbed windows.
  • Controlling visual effects.
  • There are a number of window managers available for Linux, and desktop managers have a default choices.
  • For GNOME 3, the default is mutter.
  • For KDE, the default is kwin.

GNOME (GNU Network Object Model Environment) is a popular desktop environment for Unix-like operating systems, including Linux. It provides a graphical user interface (GUI) that allows users to interact with their computers in an intuitive and user-friendly manner. GNOME focuses on providing a modern, clean, and efficient user experience while also emphasizing accessibility and usability.

GNOME vs Xserver

  • GNOME is a complete desktop environment that provides a user interface, applications, and tools for interacting with the computer.
  • X Server (X11) is a lower-level system that manages the display and rendering of graphics, enabling graphical applications and desktop environments like GNOME to function.

Desktop manager (Mutter)

The desktop manager sits above the X and window manager, it is what the user will be directly interacting with.

  • The tasks of the Desktop managers include:
  • Providing taskbar, drop-down menus
  • Offering applications
  • Giving choices for themes.

Mutter is the window manager used by the GNOME desktop environment. It works closely with the GNOME Shell, which is the user interface of GNOME. Mutter is responsible for managing the layout and appearance of windows within the GNOME desktop environment. It handles window decorations, stacking order of windows, workspace management, and visual effects like animations and compositing.

Installation

Xserver

Download Xserver from this (Link) and install it, or if you have Chocolatey installed on your machine, search for Xserver and install it.

Downloading Xserver from sourceforge.net
Installing Xserver directly from Chocolatey

After installing Xserver, you can also download and install some fonts to be used by the Xserver to display the graphical applications.

WSL 2 enables Linux GUI applications to feel native and natural to use on Windows.

  • Launch Linux apps from the Windows Start menu
  • Pin Linux apps to the Windows taskbar.
  • Use alt-tab to switch between Linux and Windows apps.
  • Cut + Paste across Windows and Linux apps.

You can now integrate both Windows and Linux applications into your workflow for a seamless desktop experience.

Apps

In this section, we will install some apps to make our life easier when we work with WSL.

Nautilus

Nautilus, also known as GNOME Files, is the file manager for the GNOME desktop. (Similar to Windows File Explorer).

sudo apt install nautilus -y
  • The installation will take some time to check the dependency, download, and install them.
  • To open the file manager, type nautilus in the terminal and the file manager will open in a pop-up.
nautilus
File manager opened with Nautilus.

Sublime

Sublime Text is a popular text editor designed for code editing and general text manipulation. It’s known for its simplicity, speed, and powerful features, making it a favorite among developers, programmers, and anyone who works with code or text files. Sublime Text is available for multiple platforms, including Windows, macOS, and Linux.

  • To install sublime, you need to add the repository where the apt tool can find the sublime-text package, so if you run the following command directly to install sublime, you will give an error.
sudo apt install sublime-text
Installing sublime using the apt tool without adding the sublime repository
  • As you see, the APT tool tried to install Sublime, and when it did not manage, it suggested installing Sublime using Snap, which is another package manager I have installed in WSL, but
  • So first, we will add the sublime-text repository first and also add the GPG key as it is needed, then repeat the install command.
curl -fsSL https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add
sudo add-apt-repository "deb https://download.sublimetext.com/ apt/stable/"
sudo apt install sublime-text
Adding sublime repository so apt can find sublime.
Installing sublime using APT package manager.
  • Now, sublime-text is installed. To open any file using sublime
subl .bashrc
  • Sublime will open the file in a pop-up window, and you don’t need to edit your files with Vim in the terminal.
Open text file using Sublime

Summary

In this article, I explained how the Graphical Interface works in Linux and its different layers (Desktop, window, and display manager). We have also installed Xmin in Windows to be able to open WSL applications in Windows.

--

--