A Possible Fix for X11 Programs Refusing to Start on Wayland

As Wayland and KDE on Wayland matures, I’ve switched my entire environment to KDE Wayland. Serious props to KDE developers — all of the Konsole and Kwin gliches I experienced in the early days are long gone.

A short aside: Why Wayland?

As an end user of Slackware, KDE and related software, I find these advantages good enough to make me switch:

Things like Pipewire and XDG portals are still rough on the edges, and parts of the Wayland stack (libinput) is not as configurable as say, xf86-input-synaptics and synclient, but I’d say the status quo is good enough for laymen like me to make the switch.

Enough rambling, let’s get on to the topic…

What environment variables?

When I started toying with KDE on Wayland (with startkwayland in Slackware), I had to run all KDE apps (KDE Gear they call it) under Wayland, otherwise they would look blurry.1 Therefore I added the following to /etc/environment:


which makes Qt apps, which most KDE apps are, to use Wayland. Next up is to make GTK apps use Wayland too, so I added:


Also some documentation recommends setting the XDG session type to Wayland too, so:


Under Qt things are all good: If a Qt app only runs on X11, typically I don’t need additional configuration to make them start with Xwayland, the method to run X11 programs on Wayland. However with GTK it’s not the case, as when I try to start Seamonkey it errors out:

Error: cannot open display: :0

I’ve fiddled with the DISPLAY and WAYLAND_DISPLAY to no avail, and put the problem aside until I remembered the Wayland environment variables. So I tried GDK_BACKEND=x11 seamonkey and sure enough, Seamonkey started up.

Onto the solution

I’ve written this helper script to start programs with the correct variables set, named xenv:

# Set some environment variables to X11

export GDK_BACKEND=x11
export QT_QPA_PLATFORM=xcb

Put this in your path and use as xenv <problematic_app>.

Have fun!



  1. This isn’t the case anymore, but still, running with native Wayland makes programs integrate better with the system.↩︎