Score:1

Launch xfce4 or other desktop in Windows 11 WSLg Ubuntu distro

bd flag

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.

cocomac avatar
cn flag
Can you launch individual apps (e.g., firefox)?
myusrn olk avatar
bd flag
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.
cocomac avatar
cn flag
So... by default, it only does individual apps, not an entire desktop envoirnment. If you want that (which is fine), I suggest [getting X410](https://x410.dev/) (no affiliation, but I like it). It isn't free, but it is very good. It is [very easy to use](https://x410.dev/cookbook/wsl/using-x410-with-wsl2/), 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.
myusrn olk avatar
bd flag
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.
Score:0
vn flag

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.
imaginabit avatar
us flag
this works but cant copy and paste text from windows clipboard
cn flag
it's worth noting that `Xwayland` can be run as normal user, so this answer is totally root-free :)
Stephan Kallweit avatar
gg flag
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!
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.