在 Windows 11 WSLg Ubuntu 发行版中启动 xfce4 或其他桌面

myu*_*olk 7 xfce xubuntu windows windows-subsystem-for-linux

我使用的是 Windows 11 WSLg(使用 Microsoft Store 中的 Windows Subsystem for Linux Preview 安装)和 Microsoft Store 中的当前 WSL Ubuntu 发行版。

如何启动xfce4或另一个 Ubuntu 桌面?

目前,apt install xfce4后跟startxfce4产生错误cannot open display: wayland-0+Failed to connect to session manager和一些其他输出。

xfce4在 Windows 10 WSL2 中,在 Windows 上安装并运行 VcXsrv 客户端后启动时没有遇到任何问题。据我了解,后者对于 Windows 11 WSLg 来说并不是必需的。

我可以毫无问题地启动独立的 x-windows 应用程序,例如xfce4-appfinder文件管理器和终端模拟器。thunar

Not*_*1ds 10

我认为主要问题是 WSLg 已经在运行 Weston,即具有自己的窗口管理器的 Wayland 参考服务器。

如果您尝试运行以下命令,您可以看到这一点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
Run Code Online (Sandbox Code Playgroud)

尝试--replace也没有什么好处,因为 Weston 实际上在不同的发行版(WSLg“系统发行版”)中运行,并且只是通过/init.

虽然我认为我仍然更喜欢这个xrdp选项,但 Wayland 确实提供了自己的 X 服务器以实现向后兼容性,因此至少不需要像 Windows 10 上那样使用像 VcXsrv 这样的第三方、基于 Windows 的 X 服务器。

通过安装它sudo apt install xwayland

在这一点上,我确信有更好的方法来做事情,但这就是我到目前为止所想到的。创建以下脚本来启动 Xfce4:

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
Run Code Online (Sandbox Code Playgroud)

当然,设置脚本可执行( +x)。

您应该获得在 Xwayland 上运行的 Xfce4 桌面。

请注意,WAYLAND_DISPLAY需要取消设置,否则 Gtk 应用程序首先尝试使用 Wayland 合成器。

另请注意,Ubuntu Desktop 则完全是另一回事,因为它依赖于 Systemd。

旁注:不过,我仍然想知道什么,因为我对 WSLg 上的 Wayland 也相当陌生:

  • 有 Xwayland 支持吗~/.Xsession?(我没能成功)
  • 当您启动 Xwayland 时,是否有其他方法可以启动会话管理器(或任何客户端)?一定有,因为Xwayland -help显示了-terminate当最后一个客户端关闭时关闭的选项。

在某些时候,我实际上可能会在一个单独的问题中问这个问题。