Skip to content

Instantly share code, notes, and snippets.

@camullen
Created December 10, 2022 23:52
Show Gist options
  • Save camullen/0c41d989ac2ad7a89e75eb3be0f8fb16 to your computer and use it in GitHub Desktop.
Save camullen/0c41d989ac2ad7a89e75eb3be0f8fb16 to your computer and use it in GitHub Desktop.
KDE Install on WSL2

Installing KDE on WSL2

Inspiration: https://www.most-useful.com/kde-plasma-on-wsl.html

Setup

  1. Update WSL
    • In windows command prompt run: wsl --update
  2. Add systemd to ubuntu
    • In ubuntu prompt run: sudo nano /etc/wsl.conf
    • Add the following to the file:
      [boot]
      systemd=true
      
    • Save and exit by pressing ctrl + o and then ctrl + x
    • Shutdown WSL by running the following in the windows command prompt: wsl --shutdown
    • Restart WSL by opening a new terminal session for Ubuntu

Installing KDE

sudo apt update

sudo apt install kubuntu-desktop

Select SDDM as display manager during setup

sudo apt install lightdm

During installation, select lightdm as default display manager using arrow keys

Edit the lightdm configuration as follows:

sudo nano /etc/lightdm/lightdm.conf

Add the following text

[Seat:*]
user-session=plasma

[LightDM]
start-default-seat=false

[XDMCPServer]
enabled=true
port=177

Save and exit by pressing ctrl + o and then ctrl + x

Setting up x server

Download and install this software for windows:

https://sourceforge.net/projects/vcxsrv/

Launch Desktop

  • From windows open the XLaunch program
  • Select the One window without titlebar option and click Next
  • Selct Open session via XDMCP and click next
  • In your ubuntu terminal you need to get the ip address of the wsl2 instance:
    • Run: sudo apt install net-tools
    • Run: ifconfig eth0 | grep inet
    • The ip address will be listed after the inet item and usually looks like 172.xxx.xxx.xxx
  • Copy the ip address above and paste into the text box next to Connect to host in the XLaunch window and click next
  • Modify the default settings to uncheck Native opengl and check Disable access control
  • Click Next
  • Click Save configuration and save the file to your desktop and name the file whatever you want
  • VITALLY IMPORTANT: When you first run VcXSrv (or XLaunch) you’ll get a Windows Firewall popup. You will need to allow it to accept connections on both the PRIVATE and PUBLIC networks. If you don’t allow PUBLIC networks you will not get a connection as the WSL Virtual Network is considered to be PUBLIC
  • Click Finish

Speeding up KDE

Fixing rendering

  • From the KDE desktop, click the start menu, go to Computer then click System Settings
  • Underneath Hardware in the left panel, click Display and Monitor
  • Select Compositor from the left panel
  • Change the rendering backend to XRender
  • Check Enable compositor on startup
  • Click Apply
Copy link

ghost commented Mar 3, 2024

Thanks, it works.

But XRender was removed, and rendering backend option is deprecated. Seems Plasma 6 will shift to Wayland. Are there alternative methods to get KDE speed up for now(Plasma 5.24.7)?

What works? I have tried hundred times and still not able to see the desktop environment in any way!

@iamqareem
Copy link

@guitarpicva any luck with this? I tried it today and I am seeing the same behavior :(

@valsamis-d I had the same problem. Looks like the reason is that kubuntu-desktop wants to access system resources (acpi, gpu, ...) which are not available on a WSL guest. Installing just kde-plasma-desktop (plus the KDE applications actually needed) instead of kubuntu-desktop solved it for me.

More notes:

  • It is no more necessary to figure out the guest's IP address. Meanwhile WSL does automatic port forwarding and you can simply use
    "localhost" in XLaunch in the "Connect to host" field.

  • So finally I got it to work (still with a few warts such as strange scaling of my desktop).

  • But I am meanwhile using a far simpler and more comfortable solution:

    • Just sudo apt install kde-plasma-desktop xrdp (and sudo apt remove lightdm if it was installed before) and restart the Linux guest.
    • Then run Windows' Remote Desktop Connection (again to "localhost"). This gives you a login screen (admittedly not very beautiful).
    • There you can log in to your KDE environment.
      (Sometimes the login does not work, apparently if you are too quick and not all services are properly running yet.
      Just try again a few seconds later.)

ohh, this has been so helpful
I followed the original instructions of the main post in vain.
& fell on this piece as I read though the comments.
It is quite direct.

copy and paste the code as provided. the inbuilt remote desktop application for windows just worked fine here too.

@guitarpicva
Copy link

guitarpicva commented Aug 13, 2024 via email

@hcschuetz
Copy link

If you allow Windows Remote Desktop client to save credentials, it seems to allow unchallenged login also.

Thanks for this hint. Works for me as well.

@Minecraft633
Copy link

VcXSrv says there are currently 0 clients connected with a black screen

@AkashaP
Copy link

AkashaP commented Jan 26, 2025

I fixed the black screen and 0 clients connected issue (and flickering every minute) by opening a powershell window and doing the following:

wsl --shutdown - restart may or may not be necessary

wsl
startx

basically X wasn't started on the linux side.

@astkaasa
Copy link

astkaasa commented Feb 5, 2025

Another successful attempt to install KDE and XRDP on ArchWSL

sudo pacman -Sy plasma packagekit-qt6

# install yay
sudo pacman -S --needed git base-devel
git clone https://aur.archlinux.org/yay.git
cd yay/
makepkg -si
yay -S xrdp xorgxrdp pipewire-module-xrdp

echo 'exec startplasma-x11' > ~/.xinitrc
sudo systemctl enable xrdp
sudo systemctl start xrdp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment