Table of Contents

Running Xorg Environments in Xwayland

This is a how-to guide for running an Xorg window manager or desktop environment in a Wayland compositor1) on Slackware 15.0 and beyond.

At the time of writing (December 2023), this is a purely academic question for most – if not all – users. As both KDE Plasma and Xfce continue to move in the direction of Wayland, however, it is not impossible that full X servers become unavailable on Slackware in future years. Xwayland provides a workaround, if an imperfect one. The process of running an Xorg environment from inside a rootful2) Xwayland session is straightforward:

All outside packages mentioned here can be found on SlackBuilds Online.

Being able to read xorg.conf is not one my goals, nor achieving a bug-for-bug compatibility with Xorg - Xwayland with !901 (merged) allows to run a full X11 desktop, even the most legacy ones (I demoed it internally here using CDE from an XDMCP remote connection for the fun 😉).3)

Choosing a Wayland compositor

The following considerations are important in choosing a Wayland compositor to run the Xwayland server:

The following two conditions can be ignored if the Xwayland version exceeds 22.1.3.

This how-to will use labwc as an example. labwc is a lightweight, wlroots-based compositor with OpenBox-style configuration.

General Configuration

General configuration requirements are limited. It is only necessary to ensure that Xwayland-capable programs open under Xwayland rather than Wayland, and that startx does something productive.

Forcing Xwayland

Any program opening in Wayland mode will be managed by the Wayland compositor directly. This can result in the appearance of poorly-behaved windows with incorrect decoration and the non-appearance of system tray items. Place the following lines in /etc/environment4) to control gtk and qt applications :

GDK_BACKEND=x11
QT_QPA_PLATFORM=xcb

For X keyboard maps other than US, it may also be necessary to specify a keymap here:

XKB_DEFAULT_LAYOUT=jp    # e.g.

startx

Instructions for starting an X session should be contained in $HOME/.xinitrc because startx will launch Xwayland. xwmconfig can set up an xinitrc file for the preferred Xorg environment if need be.

Configuring labwc

For Slackware 15.0

Create an autostart file at $HOME/.config/labwc/autostart to launch an Xwayland server with startx:

#!/bin/sh

DISPLAY=:1 startx -- /usr/bin/Xwayland

This variant closes labwc after quitting the Xorg environment to return cleanly to tty or the display manager:

#!/bin/sh

DISPLAY=:1 startx -- /usr/bin/Xwayland &
wmpid=$!
wait $wmpid
pkill -x labwc

To stop labwc from decorating the Xwayland server window, write the following to a file at $HOME/.config/labwc/rc.xml:

<labwc_config>
  <core>
    <decoration>client</decoration>
  </core>
</labwc_config>

If auto-starting xset tends to fail, try adding a few seconds of sleep before startx.

For Other Versions

These changes reflect post-15.0 Xwayland development:

DISPLAY=:1 startx -- /usr/bin/Xwayland -fullscreen -geometry 1920x1200

Ideally, the geometry option will match the dimensions of the monitor. xrandr can change the resolution afterwards.

Running

The Wayland compositor should be known to the display manager for runlevel 4 users, assuming that its package includes a desktop file. Runlevel 3 users can run the Wayland compositor directly from the command line:

$ /usr/bin/labwc

Once the autostart script has started the Xorg environment, the following commands can verify that the process worked:

$ pgrep Xorg
$ pgrep Xwayland

If there is at least one Xwayland process and no Xorg process, feel free to take a screenshot (optional) and tell your friends (not advised).

Caveats

The following caveats bear mentioning:

The above list is non-exhaustive.

Sources

1)
In Wayland terms, the “compositor” is the program responsible for displaying and managing windows. KWin is the only Wayland compositor included in Slackware 15.0.
2)
“Rootful” here means that the Wayland compositor does not manage the Xwayland window.
3)
Olivier Fourdan, xserver issue #1332
4)
Any file that controls the user profile can be used.
5)
No separate package is needed on post-15.0 systems.