Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Walkthrough

Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Walkthrough

Introduction

This article is intended for the attention of system administrators who prepare typical workplaces on computers running Windows 10, including software developers.

It should be noted that there is a certain problem associated with the impossibility of integrating software obtained from the Microsoft Store online store for use in a custom Windows 10 image. Without going into details, I will clarify that this problem is related to the fact that programs installed from the Microsoft Store communicate with the Administrator service account, and when the custom image creation is completed by the utility sysprep errors occur due to this circumstance.

The method discussed in this article avoids this problem when preparing a Windows 10 OS image with a pre-configured WSL2 subsystem, as well as a pre-prepared and configured Ubuntu 20.04 OS image with a KDE Plasma GUI, which in turn can have its own set of custom software.

There are a lot of examples and tutorials on the Internet for setting up WSL subsystems (i.e. WSL1 and the relatively new WSL2), with setting up a GUI interface for linux based OS systems from Ubuntu 16.04 to Ubuntu 20.04, but this mainly concerned desktops based on the so-called. "lightweight" xfce4, which has understandable limitations in user settings. But as far as the KDE Plasma GUI for Ubuntu 20.04 is concerned, there isn't much information found on the net. But it is this option that provides the end user with an almost unlimited set of settings for both the appearance of the system and hardware settings, of course, taking into account the current integration capabilities of linux systems implemented in the WSL2 subsystem.

Installing the required set of software and configuring WSL2

We check the current version of Windows, for this, in the Windows search bar, enter the command winver and we get something like this:

Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Walkthrough
It is important that the OS version is 1903 or 1909 (specified OS versions must be with the cumulative update KB4566116 installed), or 2004 (build number no less than 19041), the rest of the information does not matter. If the version number is less, it is recommended that you upgrade to the latest version of Windows to correctly reproduce the results in this article.

For the convenience of further actions, install the free Windows Terminal using the Microsoft Store (there is also the possibility of downloading from other sources):

Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Walkthrough
We install X Server X410 through the same Microsoft Store, this software is paid, but there is a free period of 15 days, which is enough for various tests.

Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Walkthrough
As a free alternative to X410 download and install the VcXsrv X server.

In any convenient place on the disk, we create a directory in which we will store our files. As an example, let's create a directory C:wsl.

Download the and install the Ubuntu 20.04 standalone installer, unpack the resulting file using an archiver (for example, 7-zip). Rename the unpacked directory with a long name Ubuntu_2004.2020.424.0_x64 into something more acceptable, like Ubuntu-20.04 and copy it to directory C:wsl (hereinafter simply wsl).

Download the and unpack into a directory wsl cross-platform sound server PulseAudio v.1.1., we also make corrections to its configuration files.

In file wslpulseaudio-1.1etcpulsedefault.pa In chapter Load audio drivers statically edit the line:

load-module module-waveout sink_name=output source_name=input record=0


and in the section Network access edit the line:

load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1


In file wslpulseaudio-1.1etcpulsedaemon.conf uncomment and change the line

exit-idle-time = -1


We configure the WSL2 subsystem in accordance with documentation Microsoft. The only remark is that we have already downloaded the Ubuntu distribution, and we will install it in the next step. Basically, the configuration comes down to enabling the additional components "Windows Subsystem for Linux" and "Virtual Machine Platform", and then rebooting to apply changes to the computer settings:

Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Walkthrough

If necessary, download and install the Linux kernel service pack in WSL2.
We launch Windows Terminal and select the Command Prompt mode by pressing the keys Ctrl+Shift+2.

First of all, we set the WSL2 mode of operation, for this we enter the command:

wsl  --set-default-version 2


Change to the Ubuntu 20.04 standalone bootloader directory, in my case this is wslUbuntu-20.04 and run the file ubuntu2004.exe. When prompted for a username, enter the username engineer (you can enter any other name), enter your password and confirm the entered password for the specified account:

Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Walkthrough
A terminal prompt appears, the Ubuntu 20.04 kernel is installed. Let's check the correctness of the WSL2 mode settings, for this, in the Windows Terminal, select the Windows PowerShell tab and enter the command:

wsl -l -v


the result of execution should be like this:

Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Walkthrough

We configure the Microsoft Defender firewall, i.e. disable it for the public network:

Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Walkthrough
Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Walkthrough

Setting up Ubuntu 20.04

In the Windows Terminal, select the Command Prompt tab again and install updates for Ubuntu 20.04. To do this, on the command line, enter:

sudo apt update && sudo apt upgrade –y


Install the KDE Plasma desktop:

sudo apt install kubuntu-desktop -y


installation takes up to 30 minutes, depending on the performance of the computer and the bandwidth of the Internet access channel, when prompted by the installer, we confirm OK.
Install Russian localization and dictionaries Ubuntu 20.04. To do this, on the command line, enter:

sudo apt install language-pack-ru language-pack-kde-ru -y
sudo apt install libreoffice-l10n-ru libreoffice-help-ru -y
sudo apt install hunspell-ru mueller7-dict -y
sudo update-locale LANG=ru_RU.UTF-8
sudo dpkg-reconfigure locales # ΠΏΡ€ΠΈΠΌΠ΅Ρ‡Π°Π½ΠΈΠ΅: Π²Ρ‹Π±ΠΈΡ€Π°Π΅ΠΌ ru_RU.UTF-8 UTF-8, см. ΡΠΊΡ€ΠΈΠ½ΡˆΠΎΡ‚Ρ‹ Π½ΠΈΠΆΠ΅.
sudo apt-get install --reinstall locales


Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Walkthrough
Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Walkthrough
Add the latest version of the KDE Plasma desktop:

sudo add-apt-repository ppa:kubuntu-ppa/backports
sudo apt update && sudo apt full-upgrade -y


We add our own set of console applications, for example mc ΠΈ neofetch:

sudo apt install mc neofetch -y


We check what happened, enter into the command line neofetch, see screenshot:

Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Walkthrough
Editing the WSL config file /etc/wsl.conf:

sudo nano /etc/wsl.conf


copy the text into the empty text editor window that opens:

[automount]
enabled = true
root = /mnt
options = Β«metadata,umask=22,fmask=11Β»
mountFsTab = true
[network]
generateHosts = true
generateResolvConf = true
[interop]
enabled = true
appendWindowsPath = true


save changes (Ctrl+O), confirm the operation and exit the text editor (Ctrl+X).

Exporting the customized Ubuntu-20.04 image to the directory we created wsl. To do this, in the Windows Terminal, again select the Windows PowerShell tab and enter the command:

wsl --export Ubuntu-20.04 c:wslUbuntu-plasma-desktop


the created image will help us automate the operations of launching / reinstalling the configured Ubuntu 20.04, if necessary, it will allow us to easily transfer it to another computer.

Preparing bat files and shortcuts to the Windows desktop

Using the Notepad ++ editor, create bat files (required in OEM-866 encoding for the correct output of Cyrillic characters):
File Install-Ubuntu-20.04-plasma-desktop.bat - designed to automate the initial installation of the created image of Ubuntu 20.04 on a computer with an already configured WSL2 subsystem and an X server. If the username and password differ from those specified in the example, then you need to make the appropriate changes to this bat file:

@echo off
wsl --set-default-version 2
cls
echo ΠžΠΆΠΈΠ΄Π°ΠΉΡ‚Π΅ окончания установки дистрибутива Ubuntu-20.04...
wsl --import Ubuntu-20.04 c:wsl c:wslUbuntu-plasma-desktop
wsl -s Ubuntu-20.04
cls
echo Дистрибутив Ubuntu-20.04 ΡƒΡΠΏΠ΅ΡˆΠ½ΠΎ установлСн!
echo НС Π·Π°Π±ΡƒΠ΄ΡŒΡ‚Π΅ ΡΠΌΠ΅Π½ΠΈΡ‚ΡŒ ΡƒΡ‡Π΅Ρ‚Π½ΡƒΡŽ запись ΠΏΠΎ ΡƒΠΌΠΎΠ»Ρ‡Π°Π½ΠΈΡŽ Β«rootΒ» Π½Π° ΡΡƒΡ‰Π΅ΡΡ‚Π²ΡƒΡŽΡ‰ΡƒΡŽ ΡƒΡ‡Π΅Ρ‚Π½ΡƒΡŽ запись ΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»Ρ,
echo Π»ΠΈΠ±ΠΎ ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΡƒΠΉΡ‚Π΅ ΠΏΡ€Π΅Π΄ΡƒΡΡ‚Π°Π½ΠΎΠ²Π»Π΅Π½Π½ΡƒΡŽ ΡƒΡ‡Π΅Ρ‚Π½ΡƒΡŽ запись Β«engineerΒ», ΠΏΠ°Ρ€ΠΎΠ»ΡŒ: Β«passwordΒ».
pause


File Reinstall-Ubuntu-20.04-plasma-desktop.bat - designed to reinstall the prepared image of Ubuntu 20.04 on the computer.

@echo off
wsl --unregister Ubuntu-20.04
wsl --set-default-version 2
cls
echo ΠžΠΆΠΈΠ΄Π°ΠΉΡ‚Π΅ окончания пСрСустановки дистрибутива Ubuntu-20.04...
wsl --import Ubuntu-20.04 c:wsl c:wslUbuntu-plasma-desktop
wsl -s Ubuntu-20.04
cls
echo Дистрибутив Ubuntu-20.04 ΡƒΡΠΏΠ΅ΡˆΠ½ΠΎ пСрСустановлСн!
pause


File Set-default-user.bat - to set the default user.

@echo off
set /p answer=Π’Π²Π΅Π΄ΠΈΡ‚Π΅ ΡΡƒΡ‰Π΅ΡΡ‚Π²ΡƒΡŽΡ‰ΡƒΡŽ ΡƒΡ‡Π΅Ρ‚Π½ΡƒΡŽ запись Π² Ubuntu (engineer):
c:wslUbuntu-20.04ubuntu2004.exe config --default-user %answer%
cls
echo УчСтная запись ΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»Ρ %answer% Π² Ubuntu-20.04 установлСна ΠΏΠΎ ΡƒΠΌΠΎΠ»Ρ‡Π°Π½ΠΈΡŽ!
pause


File Start-Ubuntu-20.04-plasma-desktop.bat - the actual launch of the KDE Plasma desktop.

@echo off
echo ===================================== Π’Π½ΠΈΠΌΠ°Π½ΠΈΠ΅! ============================================
echo  Для ΠΊΠΎΡ€Ρ€Π΅ΠΊΡ‚Π½ΠΎΠΉ Ρ€Π°Π±ΠΎΡ‚Ρ‹ GUI Ubuntu 20.04 Π² WSL2 Π½Π΅ΠΎΠ±Ρ…ΠΎΠ΄ΠΈΠΌΠΎ ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚ΡŒ X Server.
echo  ΠŸΡ€ΠΈΠΌΠ΅Ρ‡Π°Π½ΠΈΠ΅: Π² случаС использования VcXsrv Windows X Server Π½Π΅ΠΎΠ±Ρ…ΠΎΠ΄ΠΈΠΌΠΎ Ρ€Π°ΡΠΊΠΎΠΌΠΌΠ΅Π½Ρ‚ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ
echo  строки Π² Ρ„Π°ΠΉΠ»Π΅ Start-Ubuntu-20.04-plasma-desktop.bat, содСрТащиС "config.xlaunch" ΠΈ
echo  "vcxsrv.exe", ΠΈ Π·Π°ΠΊΠΎΠΌΠΌΠ΅Π½Ρ‚ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ всС строки, содСрТащиС "x410".
echo ============================================================================================
rem start "" /B "c:wslvcxsrvconfig.xlaunch" > nul
start "" /B x410.exe /wm /public > nul
start "" /B "c:wslpulseaudio-1.1binpulseaudio.exe" --use-pid-file=false -D > nul
c:wslUbuntu-20.04Ubuntu2004.exe run "if [ -z "$(pidof plasmashell)" ]; then cd ~ ; export DISPLAY=$(awk '/nameserver / {print $2; exit}' /etc/resolv.conf 2>/dev/null):0 ; setxkbmap us,ru -option grp:ctrl_shift_toggle ; export LIBGL_ALWAYS_INDIRECT=1 ; export PULSE_SERVER=tcp:$(grep nameserver /etc/resolv.conf | awk '{print $2}') ; sudo /etc/init.d/dbus start &> /dev/null ; sudo service ssh start ; sudo service xrdp start ; plasmashell ; pkill '(gpg|ssh)-agent' ; fi;"
rem taskkill.exe /F /T /IM vcxsrv.exe > nul
taskkill.exe /F /T /IM x410.exe > nul
taskkill.exe /F /IM pulseaudio.exe > nul


File Start-Ubuntu-20.04-terminal.bat - launching a graphical terminal without the KDE Plasma desktop.

@echo off
echo ===================================== Π’Π½ΠΈΠΌΠ°Π½ΠΈΠ΅! ============================================
echo  Для ΠΊΠΎΡ€Ρ€Π΅ΠΊΡ‚Π½ΠΎΠΉ Ρ€Π°Π±ΠΎΡ‚Ρ‹ GUI Ubuntu 20.04 Π² WSL2 Π½Π΅ΠΎΠ±Ρ…ΠΎΠ΄ΠΈΠΌΠΎ ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚ΡŒ X Server.
echo  ΠŸΡ€ΠΈΠΌΠ΅Ρ‡Π°Π½ΠΈΠ΅: Π² случаС использования VcXsrv Windows X Server Π½Π΅ΠΎΠ±Ρ…ΠΎΠ΄ΠΈΠΌΠΎ Ρ€Π°ΡΠΊΠΎΠΌΠΌΠ΅Π½Ρ‚ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ
echo  строки Π² Ρ„Π°ΠΉΠ»Π΅ Start-Ubuntu-20.04-plasma-desktop.bat, содСрТащиС "config.xlaunch" ΠΈ
echo  "vcxsrv.exe", ΠΈ Π·Π°ΠΊΠΎΠΌΠΌΠ΅Π½Ρ‚ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ всС строки, содСрТащиС "x410".
echo ============================================================================================
rem start "" /B "c:wslvcxsrvconfig.xlaunch" > nul
start "" /B x410.exe /wm /public > nul
start "" /B "c:wslpulseaudio-1.1binpulseaudio.exe" --use-pid-file=false -D > nul
c:wslUbuntu-20.04Ubuntu2004.exe run "cd ~ ; export DISPLAY=$(awk '/nameserver / {print $2; exit}' /etc/resolv.conf 2>/dev/null):0 ; export LIBGL_ALWAYS_INDIRECT=1 ; setxkbmap us,ru -option grp:ctrl_shift_toggle ; export PULSE_SERVER=tcp:$(grep nameserver /etc/resolv.conf | awk '{print $2}') ; sudo /etc/init.d/dbus start &> /dev/null ; sudo service ssh start ; sudo service xrdp start ; konsole ; pkill '(gpg|ssh)-agent' ;"
taskkill.exe /F /T /IM x410.exe > nul
rem taskkill.exe /F /T /IM vcxsrv.exe > nul
taskkill.exe /F /IM pulseaudio.exe > nul


Also for ease of use in the catalog wsl we prepare shortcuts pointing to the corresponding bat-files. Then the contents of the directory wsl as follows:

Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Walkthrough

Launching the KDE Plasma Desktop

We check that all the preparatory steps have been completed, we try to launch the shortcut Plasma-desktop. A password request appears, enter the password for the account and ... the window closes. It's okay the first time. We try again - and we see the familiar KDE Plasma taskbar. We customize the appearance of the taskbar, in the example, for ease of use, the panel is moved to the right side of the screen and centered. We check the localization settings, if necessary, add the Russian language:

Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Walkthrough

If necessary, we bring shortcuts for installed linux applications to the KDE Plasma taskbar.

If Ubuntu 20.04 requires you to log out of your user account in order to apply changes to the settings, or you need to restart the OS, to do this, in Windows Terminal, enter the command:

wsl -d Ubuntu20.04 --shutdown


With a shortcut Plasma-desktop or Konsole you can run the KDE Plasma Ubuntu 20.04 GUI. For example, install with Konsole GIMP graphics editor:

Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Walkthrough
After installation is complete, run from Konsole GIMP graphics editor:

Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Walkthrough
GIMP works, which is what I wanted to check.
And here is how various linux applications work in KDE Plasma in WSL2:

Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Walkthrough
the customized KDE Plasma taskbar is on the right side of the screen. and the video in the Firefox window plays with sound.

Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Walkthrough
Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Walkthrough

If necessary, you can configure access to Ubuntu20.04 by SSH ΠΈ RDP, for this you need to install the appropriate services with the command:

sudo apt install ssh xrdp -y


note: to enable password access by SSH you need to edit the file /etc/ssh/sshd_config, namely the parameter PasswordAuthentication no must be set to PasswordAuthentication yes, save changes and reboot Ubuntu20.04.

Each time you start Ubuntu20.04, the internal ip address changes, before setting up remote access, you need to check the current ip address using the command ip a:

Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Walkthrough
Accordingly, this ip-address must be entered in the session settings SSH ΠΈ RDP before starting.
This is what remote access looks like SSH using MobaXterm:

Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Walkthrough
And this is what remote access looks like RDP:

Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Walkthrough

Using x server vcxsrv instead of x410

Launching and setting up vcxsrv, carefully set the appropriate checkboxes:

Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Walkthrough
Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Walkthrough
Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Walkthrough
Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Walkthrough
Saving the configured configuration in the directory wslvcxsrv with standard name config.xlaunch.

Editing bat files Start-Ubuntu-20.04-plasma-desktop.bat ΠΈ Start-Ubuntu-20.04-terminal.bat according to their instructions.

Launching the shortcut Plasma-desktop, and this is what we get:

Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Walkthrough
The KDE Plasma desktop completely closes the Windows desktop, to switch between windows of linux and windows applications we use the well-known key combination Alt+Tab, which is not very convenient.
In addition, an unpleasant feature of the X server was revealed vcxsrv - it crashes when launching some applications, in particular the same GIMP or LibreOffice Writer. Perhaps we should wait until the developers remove the noticed "bugs", but this is not certain ... So, to get acceptable results, it is better to use the X Server Microsoft x410.

Conclusion

Still, we must pay tribute to Microsoft, the WSL2 product turned out to be quite working, and in my inexperienced opinion, very successful. And as far as I know, the developers continue to intensively "finish" it, and perhaps - in a year or two, this subsystem will appear in all its functional completeness.

Source: habr.com

Add a comment