7

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.

4
  • Can you launch individual apps (e.g., firefox)?
    – cocomac
    Jan 7, 2022 at 2:28
  • yes i can launch individual apps no problem which is what you see demonstrated in typical windows 11 wslg release videos highlighting there being no need for an x-client [ e.g. vcsrv or xming ] running on windows host with this release.
    – myusrn olk
    Jan 7, 2022 at 5:11
  • So... by default, it only does individual apps, not an entire desktop envoirnment. If you want that (which is fine), I suggest getting X410 (no affiliation, but I like it). It isn't free, but it is very good. It is very easy to use, and supports individual apps, and a full desktop envoirnment, like xfce4. If you prefer something free, you could install xrdp, and just connect to the WSL2 GUI via Remote Desktop.
    – cocomac
    Jan 7, 2022 at 5:18
  • k, I've used xrdp before so i'll compare that with the x410 suggestion and go with one of those. since x410 appears to be an xserver i'm concerned that it will overlap with the integrated xserver / wayland services wslg uses to enable x-apps to run. i didn't think that the wslg implementation could enable xserver/client or wayland support for x-app windows and not also include desktop x-app window as well.
    – myusrn olk
    Jan 7, 2022 at 6:16

1 Answer 1

9

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.

3
  • 1
    this works but cant copy and paste text from windows clipboard
    – imaginabit
    Oct 13, 2022 at 4:17
  • it's worth noting that Xwayland can be run as normal user, so this answer is totally root-free :) Jan 18 at 12:51
  • Thanks a lot for this post. It helped as well recover the use of xfce4 after updating wsl2 under win10 recently. Without the proposed script, xfce4 was ending with an I/O Error and a segmentation fault using XLaunch. So instead of reinstalling the 20.04 version, which is recommended in other posts, please try this approach first! Apr 20 at 8:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .