Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Launch xfce4 or other desktop in Windows 11 WSLg Ubuntu distro

I’m using Windows 11 WSLg (installed using the Windows Subsystem for Linux Preview from the Microsoft Store) and the current WSL Ubuntu distribution from the Microsoft Store.

How can I launch xfce4 or another Ubuntu desktop?

Currently an apt install xfce4 followed by startxfce4 produces the errors cannot open display: wayland-0 + Failed to connect to session manager and some other output.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

With Windows 10 WSL2, I didn’t hit any issues launching xfce4 after the VcXsrv client was installed and running on Windows. The latter, as I understand it, isn’t supposed to be necessary with Windows 11 WSLg.

I can launch standalone x-windows apps like the xfce4-appfinder, thunar file manager, and terminal emulator without issues.

>Solution :

I believe the main problem is that WSLg is already running Weston, the Wayland reference server with its own window manager.

You can see this if you try to run just xfwm4:

xfwm4-Message: 02:10:49.361: Another Window Manager (Weston WM) is already running on screen :0.0
xfwm4-Message: 02:10:49.361: To replace the current window manager, try "--replace"

(xfwm4:267): xfwm4-WARNING **: 02:10:49.361: Could not find a screen to manage, exiting

Attempting to --replace does no good either, since Weston is actually running in a different distribution (the WSLg "System Distribution") and is just connected to your instance via sockets which are injected by /init.

While I think I still prefer the xrdp option, Wayland does provide its own X server for backward compatibility, so at least there’s no need for a third-party, Windows-based X server like VcXsrv as there was on Windows 10.

Install it via sudo apt install xwayland.

At this point, I’m sure there’s a better way of doing things, but here’s what I’ve come up with so far:

Xwayland :1 &
WAYLAND_DISPLAY= DISPLAY=:1 xfce4-session

You should get an Xfce4 desktop running on Xwayland.

Note that WAYLAND_DISPLAY needs to be unset or else Gtk apps will attempt to use the Wayland compositor first.

Also note that Ubuntu Desktop is a whole other story since it depends on Systemd.

What I’d still like to know, though, since I’m fairly new to Wayland on WSLg as well:

  • Is there Xwayland support for ~/.Xsession? (I couldn’t make it work)
  • Is there any other way to launch the session manager (or any client) when you launch Xwayland? There must be, since Xwayland -help shows a -terminate option for shutting down when the last client closes.
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading