Logo

dev-resources.site

for different kinds of informations.

Setting up Arch Linux with KDE Plasma in Windows Subsystem for Linux 2

Published at
12/11/2020
Categories
archlinux
kde
wsl
windows
Author
rashil2000
Categories
4 categories in total
archlinux
open
kde
open
wsl
open
windows
open
Author
10 person written this
rashil2000
open
Setting up Arch Linux with KDE Plasma in Windows Subsystem for Linux 2

Yup, you read that right. Sounds crazy, I know. But entirely possible, and surprisingly usable. Pretty easy too.

Enabling Windows Subsystem for Linux

Follow this official guide - Windows Subsystem for Linux Installation Guide for Windows 10 - to enable WSL on Windows. Make sure you follow till step 5 of the manual method to have WSL2 as default. Everything is explained in great detail in the guide.

Now, there are two ways to install Arch - the first one is extremely easy and preferable, and the second is for those who like to have more fine-grain control over stuff.

Installing Arch Linux - Method I

Arch Linux used to be an official app on the Windows Store some time ago, but the Arch community isn't onboard with the concept of WSL, or they aren't exactly comfortable with how easy WSL makes Linux installations for Windows users. Not to worry though, since both Arch Linux and the WSL kernel are open source, you can just easily install it manually too. Follow the steps given in this short guide How to Setup | ArchWSL Documentation.

Installing Arch Linux - Method II

We will use a tool called LxRunOffline to install and manage WSLs on our system. Open up Administrator CMD and run the following commands:

cd %USERPROFILE%\Downloads
curl -LO https://github.com/DDoSolitary/LxRunOffline/releases/download/v3.5.0/LxRunOffline-v3.5.0-msvc.zip
powershell -c Expand-Archive LxRunOffline-v3.5.0-msvc.zip
cd LxRunOffline-v3.5.0-msvc
copy LxRunOffline.exe C:\Windows
Enter fullscreen mode Exit fullscreen mode

The last line copies the LxRunOffline.exe file to a location which is included in PATH environment variable, so that we can call this from anywhere. Here, for example, it copies this to 'C:\Windows' (this is why elevated access is required).

Now, we have to download Arch rootfs. In CMD, run:

cd %USERPROFILE%\Downloads
curl -LO https://mirrors.edge.kernel.org/archlinux/iso/2020.12.01/archlinux-bootstrap-2020.12.01-x86_64.tar.gz
Enter fullscreen mode Exit fullscreen mode

Once the download is complete, we can instruct LxRunOffline to start the extraction:

mkdir D:\WSL\Arch
LxRunOffline i -n Arch -d D:\WSL\Arch\ -f %USERPROFILE%\Downloads\archlinux-bootstrap-2020.12.01-x86_64.tar.gz -r root.x86_64
Enter fullscreen mode Exit fullscreen mode

Instead of 'D:\WSL\Arch\', you can specify any location path. Also, make sure the path doesn't have any spaces (Linux doesn't like spaces). This can take a bit of time.

After that, run:

wsl --set-version Arch 2
wsl ~ -d Arch
Enter fullscreen mode Exit fullscreen mode

By default, Arch is installed as an instance of WSL1. We don't want that, so the first line fixes that. The second line runs the Arch distribution (the '~' tells it to open in the default home directory).

Now the rootfs we downloaded was an absolute minimal install, and includes nothing by default. To add to the problem, the package manager pacman wouldn't run because all the mirrors in '/etc/pacman.d/mirrorlist' are commented by default, and we don't even have a text editor to uncomment them! To fix this, we just open it in notepad (life hack!):

notepad.exe /etc/pacman.d/mirrorlist
Enter fullscreen mode Exit fullscreen mode

Uncomment the three worldwide mirrors (or the ones based on your location). After that, we will install the basic utilities and a terminal text editor:

pacman-key --init
pacman-key --populate archlinux
pacman -Sy base base-devel nano
Enter fullscreen mode Exit fullscreen mode

Next we'd want to add a non-root user. Run the following to create a user username and give it a password:

useradd -m -G wheel username
passwd username
EDITOR=nano visudo
Enter fullscreen mode Exit fullscreen mode

Here, uncomment the line that says %wheel ALL=(ALL) ALL, save and exit the editor.

Exit Arch. To make this new user the default user of Arch, run this in CMD:

LxRunOffline su -n Arch -v 1000
Enter fullscreen mode Exit fullscreen mode

The next time you start Arch, it'll start as username.

Installing KDE Plasma

After you've created a non-root user, run the following commands in Arch's bash shell to update existing packages and install the KDE Plasma desktop environment:

sudo pacman -Syu plasma
Enter fullscreen mode Exit fullscreen mode

Now there are multiple ways of enabling displays in WSL2 - X display forwarding, Virtual Network Computing and Remote Desktop Protocol. We'll cover two of them, first X and second VNC. While I was able to set up RDP connections in Debian-based WSLs, I couldn't get it to work in Arch.

The first method is extremely easy - just a few clicks - and doesn't involve inputting commands. However, it might not be as responsive and reliable (when you might have multiple WSL distros) as the second. The second method requires heavy use of the commandline - for installing packages and editing configs.

Enabling GUI display - Method I

Configuring a proper X-server for WSL was always a pain, until now. Enter GWSL, a preconfigured X-server that uses VcXsrv under the hood. Since it is a general purpose X-server, it can be used for making graphical SSH connections, launching individual Linux apps and other cool stuff. Here we'll just press a couple of buttons to start KDE in Arch.

First run

Go to the Store page or pull down the latest release from its releases page and install it. Upon first launch, it'll ask for Firewall permissions; give it both Public and Private access. Once that's done, right click on the icon on the taskbar and set the Default Window Mode to 'Single Window Mode'. This is done because we want to launch the DE as a whole; this can be skipped if you just want to run Linux app GUIs in their own separate windows, through the Linux apps option in GWSL dashboard (after exporting the display variable).

Export environment variable

Once that's done, left-click on the same icon to pull up the GWSL Dashboard. From there, select GWSL Distro Tools (and select Arch from there if you have multiple distros). Click on 'Auto-Export Display'. It'll automatically restart Arch for the changes to take effect.

Command shortcut

Now we need to tell GWSL how to launch KDE. Open up the dashboard again and select Shortcut Creator. In this window:

  • Put a name of your choice in the 'Shortcut Label' field, for example KDE-Plasma.
  • The 'Shortcut Command' is dbus-launch startplasma-x11.
  • For the 'Run In' field, select Arch.

Click on 'Add this to Start menu' to finish.

Now launch this shortcut from the Start menu, and focus on the VcXsrv window. Viola, we're in Plasma!

GWSL method

Enabling GUI display - Method II

VNC allows us to send input and receive graphical output over a network, and we'll use TigerVNC server on our Arch subsystem and TigerVNC client on our Windows host system.

Configuring systemd

Arch Linux allows running VNC servers only as a system service, so we'll have to make sure we have a usable systemd. This is also mentioned as an optional step in the How to Setup | ArchWSL Documentation page. We'll use genie in this tutorial.

Installing genie would have been a lot easier, but unfortunately, because of reasons aforementioned, genie was pulled down from AUR. We can download and install the PKGBUILD (source) manually. The original PKGBUILD file has some license file issue, so I've modified the file and we'll use that. Run the following in bash:

sudo pacman -S base-devel
curl -Lo PKGBUILD https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=daemonize
makepkg -si
rm PKGBUILD
curl -Lo PKGBUILD https://gist.githubusercontent.com/rashil2000/f148d5fd207eb30c43f269dcd4f7c6fb/raw/73db1b0a14634c23b35a01168b5068aee877b74c/PKGBUILD-release
makepkg -si
rm PKGBUILD
Enter fullscreen mode Exit fullscreen mode

The first command installs the packages needed to build other packages manually (you might get a warning regarding fakeroot, press 'n' for that). The next three commands install daemonize, a dependency for genie. The last three install genie itself, from my modified PKGBUILD.

Installing VNC server

pacman can be used to install TigerVNC server, while we can directly download and run the Windows client binary.

sudo pacman -S tigervnc
curl -Lo ~/.local/bin/vncviewer.exe --create-dirs https://bintray.com/tigervnc/stable/download_file?file_path=vncviewer64-1.11.0.exe
chmod +x ~/.local/bin/vncviewer.exe
vncpasswd
sudo nano /etc/tigervnc/vncserver.users
Enter fullscreen mode Exit fullscreen mode

You should immediately set a password for your VNC server using vncpasswd (you can skip view-only password). The last command opens up a config. file where you need to put a new line saying :1={username}, where username is the name of the non-root user you set earlier (remove the braces). See the examples given in that file if you're confused.

Running VNC client

genie -i
genie -c sudo systemctl start vncserver@:1
~/.local/bin/vncviewer.exe -passwd ~/.vnc/passwd 127.0.0.1:1
Enter fullscreen mode Exit fullscreen mode

The first command enables systemd. The second one starts up the VNC server as a service at the first VNC port. The third connects the Windows client to that server.

Viola, again! You'll have to run these three commands every time you'd like to spin up the GUI.

VNC method

Enabling audio forwarding

coming soon

Again this is something that I was able to do only in Debian-based distros, through PulseAudio server. No luck in Arch yet...


This tutorial has been tested (somewhat) widely - on a 10-year-old PC, a modern gaming laptop and a current-gen Macbook (through Bootcamp).
kde Article's
30 articles in total
Favicon
(Quick-note) Troubleshooting Dual Monitor Issues on KDE on Ubuntu/ Linux Mint
Favicon
bash: No such file or directory
Favicon
How To Unhide Titlebars on Maximised Windows in KDE Plasma 6
Favicon
DinaWall 0.2
Favicon
How to enable auto dark mode (night theme) in KDE Plasma
Favicon
Using KConfig with Rust
Favicon
Bitflags in Rust
Favicon
Season of KDE 2022
Favicon
Creating Rust/QML Project using Templates
Favicon
My sleek and modern Linux development machine in 2021
Favicon
Activate USB Wi-Fi Receiver from Terminal
Favicon
KDE Development with Podman
Favicon
My KDE Workfloaw
Favicon
How to recover KDE if it doesn't load after updating FreeBSD from 12.x to 13.0-RELEASE
Favicon
Fuck FreeBSD
Favicon
The state of Linux as a daily use OS in 2021
Favicon
SPOTIFY SYSTEM TRAY [KDE]
Favicon
Fedora - KDE development journey (Qt5X11Extras)
Favicon
Fedora - KDE development journey (Qt5UiPlugin)
Favicon
Fedora - KDE development journey (Qt5Qml / qmake)
Favicon
KDE vs GNOME
Favicon
Setting up Arch Linux with KDE Plasma in Windows Subsystem for Linux 2
Favicon
âš™ My Arch Linux setup
Favicon
Writing a KDE Plasmoid to display JioFi Stats
Favicon
KDE Plasma & ssh keys
Favicon
Trying out KDE
Favicon
My (k)Ubuntu (OSX look alike) desktop setup
Favicon
KDE Neon on 2017 MacBook Air
Favicon
Script your Yakuake with default tabs
Favicon
How to execute Firefox with support for KDE filepicker

Featured ones: