About Blog Contact

Updating to Ubuntu 21.04: Using X11 Under Wayland

I’ve recently updated to Ubuntu 21.04. A significant change is the replacement of X by Wayland. Many modern GUI development kits already support Wayland, so a program developed with GTK3 or Qt 5 should work without any issues. An X11 server can also be run as a client under Wayland, so programs with only X11 support can connect with that X server without it knowing the difference. To accomodate the large number of X11 clients in its more than 30 years of history, Ubuntu setup such a X server by default.

However, for programs that knows about Wayland and tries to run in Wayland mode, but still have some bugs with Wayland support, there might be some problems. For example, klayout segfaults upon starting:

$ klayout
Info: Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
Aborted (core dumped)

XDG_SESSION_TYPE is an environment variable set by display managers, indicating the type of current session (see here). GUI libraries may use it to determine which window system it should use. In the example shown, apparently the Qt library is unhappy about using Wayland while the display manager is Gnome. Though it’s unhappy and claimed to be ignoring XDG_SESSION_TYPE=wayland, it did not fall back to X11 correctly. So what we should do is explictly tell Qt to use X11 and forget Wayland altogether:

XDG_SESSION_TYPE=x11 klayout

Problem solved!

I also used this workaround to (partially) fix Zoom Linux client’s screenshare bug. When starting in Wayland mode, it cannot detect any window or screen, so it can’t share them. When starting in X11 mode however, it can detect the windows of programs who are also in X11 mode. I’ve filed a bug to zoom.