8

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.

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.

NotTheDr01ds
  • 22,082

1 Answers1

12

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. Create the following script to launch Xfce4:

#!/usr/bin/sh
Xwayland :1 &
xw_pid=$!
WAYLAND_DISPLAY= DISPLAY=:1 dbus-launch startxfce4
kill $xw_pid

Of course, set the script executable (+x).

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.

Side-note: 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.

At some point I might actually ask this in a separate question.

NotTheDr01ds
  • 22,082