Skip to content

Suggestions to improve wayland support.

I have successfully used Xfce4 4.20 with Wayland. Even make it work out-of-the-box (sysvinit+elogind+seatd) for my Linux distribution.

Captura_de_pantalla_2024-12-25_02-42-05

My suggestions to have an Xfce4 Session with Wayland are:

  1. Xfce should use its own Labwc config and environment files (ex: ~/.config/xfce4/labwc/rc.xml and ~/.config/xfce4/labwc/environment) to avoid conflict with a existent setup of labwc that would launch anything from ~/.config/labwc/autostart. This Also will allow to set an specific Labwc configuration for Xfce.
  2. Wayland session should set XDG_SESSION_TYPE, GDK_BACKEND, QT_QPA_PLATFORM, CLUTTER_BACKEND, SDL_VIDEODRIVER and MOZ_ENABLE_WAYLAND environment variables.
  3. labwc should be started using dbus-run-session as wrapper to make sure Xfce4 session starts as D-Bus session and make everything work.

So I took rc.xml en environment example files from doc/ directory from Labwc, customized them and put them inside /usr/share/xfce4/labwd. Basically setting theme and keyboard map to match defaults from my Linux distribution.

Next, took startxfce4 script and modified it to match the three point above.

diff -Naur xfce4-session-4.20.0.orig/scripts/startxfce4.in xfce4-session-4.20.0/scripts/startxfce4.in
--- xfce4-session-4.20.0.orig/scripts/startxfce4.in	2024-12-25 03:05:03.678394203 -0600
+++ xfce4-session-4.20.0/scripts/startxfce4.in	2024-12-25 03:11:45.818341240 -0600
@@ -51,6 +51,21 @@
     then
       XFCE4_SESSION_COMPOSITOR="1"
       export XFCE4_SESSION_COMPOSITOR
+      # freedesktop specifications mandate that the definition
+      # of XDG_SESSION_TYPE should be respected
+      XDG_SESSION_TYPE="wayland"
+      export XDG_SESSION_TYPE
+      # Make sure all toolkits use their Wayland backend
+      GDK_BACKEND="wayland"
+      export GDK_BACKEND
+      QT_QPA_PLATFORM="wayland"
+      export QT_QPA_PLATFORM
+      CLUTTER_BACKEND="wayland"
+      export CLUTTER_BACKEND
+      SDL_VIDEODRIVER="wayland"
+      export SDL_VIDEODRIVER
+      MOZ_ENABLE_WAYLAND="1"
+      export MOZ_ENABLE_WAYLAND
     else
       # append
       OPTS="$OPTS $OPT"
@@ -73,7 +88,23 @@
       echo "$0: Please either install $default_compositor or specify another compositor as argument"
       exit 1
     fi
-    XFCE4_SESSION_COMPOSITOR=${OPTS:-labwc --startup}
+    # Create specific labwc directory for Xfce
+    if [ ! -d "${HOME}/.config/xfce4/labwc" ]; then
+       mkdir -p "${HOME}/.config/xfce4/labwc"
+    fi
+    # Copy specific labwc configuration file for Xfce
+    if [ ! -f "${HOME}/.config/xfce4/labwc/rc.xml" ]; then
+       cp -p @_datadir_@/xfce4/labwc/labwc-rc.xml "${HOME}/.config/xfce4/labwc/rc.xml"
+    fi
+    # Copy specific labwc environment file for Xfce
+    if [ ! -f "${HOME}/.config/xfce4/labwc/environment" ]; then
+       cp -p @_datadir_@/xfce4/labwc/labwc-environment "${HOME}/.config/xfce4/labwc/environment"
+    fi
+    # Use dbus-run-session to make sure session starts as D-Bus session
+    # Also: Xfce **SHOULD** use its own config directory and config file
+    # to avoid conflict with current labwc setup and avoid launching 
+    # anything from ~/.config/labwc/autostart
+    XFCE4_SESSION_COMPOSITOR=${OPTS:-dbus-run-session -- /usr/bin/labwc --config-dir ${HOME}/.config/xfce4/labwc --config ${HOME}/.config/xfce4/labwc/rc.xml --startup}
   fi
 fi

startxfce4.zip

Please, review the modified startxfce4 script in the attachment. Should I make a pull request?

The results were very pleasant. Had an Xfce4 session with Wayland with everything working perfectly (sound, xfsettingsd, xfce4-powermananager, gpg-agent, etc), except for Xfce keyboard shortcuts and desktop workspaces (limitations from using Labwc). I will try on the weekend to make something similar with Wayfire, which is a more robust and full-featured Wayland compositor.

Captura_de_pantalla_2024-12-25_02-43-21a

Edited by Joel Barrios