« Previous 1 2 3 4 Next »
WSL puts Linux on Windows desktops
Sublease
X11 Applications with RDP
At the command line, at least, WSL brings Windows and Linux closer together and makes work more flexible. Microsoft did not intend users to launch graphical Linux applications in WSL, but you do have several approaches to achieve this. The creators of Kali Linux take a detour via the Remote Desktop Protocol (RDP) on top of Linux's own X Window System (X11) and provide a script that you can download and execute in the Kali shell with the commands:
wget https://kali.sh/xfce4.sh sudo sh xfce4.sh
The script downloads and sets up the Xfce desktop environment customized for Kali and the free Xrdp RDP server with all dependencies, which takes a while and is reflected in additional memory requirements of more than 1GB. Typing
sudo /etc/init.d/xrdp start
starts the RDP server, which then accepts connections on TCP port 3390. With the use of the graphical client of the remote desktop connection or
mstsc.exe /v:127.0.0.1:3390
at the Windows command line, you can then start the Kali Linux desktop. After completing your work, log off from the desktop and quit the RDP server in the shell,
sudo /etc/init.d/xrdp stop
to ensure that the Linux instance terminates cleanly when leaving the shell and does not continue to run in the background.
This approach is quickly put into operation, but the problem is that the X11 protocol tunnels in RDP and thus only starts complete desktop sessions and not individual applications.
X Server X410 Application Window
A more elegant solution without a detour via RDP requires an X server on Windows. The X410 X server is unfortunately not free of charge, but it was specially developed for integration with WSL; you can pick it up as an app from the Microsoft Store [7]. If you launch the app, it initially only shows up as an X icon in the system tray. You then need to use the icon's context menu to configure the operating mode.
In Windowed Apps mode, X410 acts as a window manager and waits for you to start individual applications in a Linux instance that behave like native Windows applications, are displayed in separate windows, and can be positioned and resized arbitrarily on the Windows desktop. The Floating Desktop , on the other hand, expects a complete Linux desktop session to start and displays it in a window (Figure 3). The Full Desktop executes the Linux desktop, not surprisingly, in full-screen mode.
If not already installed, install the Xfce window manager in your Linux instances. On Ubuntu you can do so with the command:
sudo apt-get install xfce4 xfce4-terminal
Kali Linux comes with a customized version of Xfce, in which case, you need to type
sudo apt-get install kali-desktop-xfce
The steps that follow are identical in the two distributions. Make sure that X410 is started in Floating Desktop
mode; then, export the DISPLAY
environment variable in the shell and start the desktop environment:
export DISPLAY=127.0.0.0.1:0.0 xfce4-session
The desktop session then starts on Windows in its own window. To accelerate startup, permanently add the DISPLAY
variable to the login script of the Linux shell:
echo "export DISPLAY=127.0.0.1:0.0" >> ~/.bashrc
In Windows, create a batch script with the content:
start /B x410.exe /desktop ubuntu.exe run "if [ -z \"$(pidof xfce4-session)\" ]; then export DISPLAY=127.0.0.1:0.0; xfce4-session; pkill '(gpg|ssh)-agent'; taskkill.exe /IM x410.exe; fi;"
You can replace the ubuntu.exe
with kali.exe
and start the X window manager and the Linux desktop in one fell swoop. The how-tos on the X410 website explain how to get started in an even more elegant way without an annoying console window and how to make the Linux desktop look better.
No Desktop At All
If you prefer to do without the complete desktop environment, a variation of this approach also works for individual applications:
start /B x410.exe /wm ubuntu.exe run "if [ -z \"$(pidof xfce4-session)\" ]; then export DISPLAY=127.0.0.1:0.0; firefox; pkill '(gpg|ssh)-agent'; taskkill.exe /IM x410.exe; fi;"
The /wm
option launches X410 in Windowed Apps
mode; in the shell command, an application (in this case, the Mozilla Firefox browser) replaces the Xfce desktop environment. The DPI Scaling | High Quality
option in the context menu of the tray icon ensures that the windows are upscaled to HiDPI displays. However, in the environment here, this caused some fuzziness in the view.
Therefore, it makes more sense to scale supported applications natively in Linux on displays with very high resolution. This can be achieved for Firefox from the previous example and other applications that use the GTK GUI toolkit and its GDK library (top command) and for applications based on the Qt GUI toolkit (bottom command):
export GDK_SCALE=2 export QT_SCALE_ FACTOR=2
Afterward, Linux applications can hardly be distinguished from native Windows applications, even with HiDPI resolution.
« Previous 1 2 3 4 Next »
Buy this article as PDF
(incl. VAT)
Buy ADMIN Magazine
Subscribe to our ADMIN Newsletters
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Most Popular
Support Our Work
ADMIN content is made possible with support from readers like you. Please consider contributing when you've found an article to be beneficial.