What you’ll learn
In this tutorial, we will create a snap of a Wayland-native application to act as the graphical user interface (GUI) for an IoT or kiosk device. We will walk through the process and solve some common problems along the way. For the introduction to this tutorial series and the Mir display server please visit here.
Wayland is a new protocol that enables 3D compositors to be used as primary display servers, instead of running the 3D compositor as an extension under the (2D) X.org display server. Or, in layman's terms, it assumes you're using a 3D desktop from the start, instead of bolting on 3D capabilities to an 2D framework. Wayland is the “new” (13 years old already) display server technology on Linux, which is supposed to replace the antiquated X11. It promises better security, performance, portability, everything, compared to X11, and it sure does deliver, provided that you’re not using unsupported graphics cards.
The combination of Snap, the “mir-kiosk” Wayland server, and Ubuntu Core ensures the reliability and security for any graphical embedded device application.
What you’ll need
- An Ubuntu desktop running any current release of Ubuntu, or an Ubuntu Virtual Machine on another OS.
- A ‘Target Device’ from one of the following:
A device running Ubuntu Core 18.
This guide shows you how to set up a supported device. If there’s no supported image that fits your needs you can create your own core image.A VM. You don’t have to have a physical “Target Device”, you can follow this tutorial using Ubuntu Core in a VM instead.
Install the ubuntu-core-vm snap:
sudo snap install --beta ubuntu-core-vm --devmode
For the first run, create a VM running the latest Core 18 image:
sudo ubuntu-core-vm init
.From then on, you can spin it up with:
sudo ubuntu-core-vm
Which should show you a new window with Ubuntu Core running inside. Setting up Ubuntu Core on this VM is the same as for any other device or VM. See, for example, https://developer.ubuntu.com/core/get-started/kvm.
Using Ubuntu Classic You don’t have to use Ubuntu Core, you can use also a “Target Device” with Ubuntu Classic. Read this guide to understand how to run kiosk snaps on your desktop, as the particular details won’t be repeated here.
Originally authored by Gerry Boland
Translation(s): English - Français
Wayland is a communication protocol that specifies the communication between a display server and its clients. A display server using the Wayland protocol is called a Wayland compositor, because it additionally performs the task of a compositing window manager.
The aim of Wayland is replacing the X Window System (Also known as X11, or Xorg) with a modern, secure, and simpler windowing system. As part of its efforts, the Wayland project also develops a reference implementation of a Wayland compositor called Weston. Major desktops such as KDE Plasma and GNOME have implemented their own Wayland compositors.
Contents
- Wayland
- Usage
- Desktops
- Applications
- Display Managers
- Troubleshooting
- FAQ
- Usage
Usage
Hardware requirements
It's important firstly to check your hardware and make sure it's compatible with your choice of desktop. The divide right now is strictly between two buffer APIs, GBM and EGLStreams. NVIDIA GPUs using the proprietary driver support EGLStreams, while all other graphics cards and driver combinations support GBM. A Wayland compositor needs to explicitly support one or both of these APIs in order to function.
As it stands, GNOME (using Mutter) supports both GBM and EGLStreams well. KDE Plasma (using KWin) supports GBM in all versions, and EGLStreams since Plasma 5.16. All other compositors only support GBM and will not function with the proprietary NVIDIA driver in use.
Desktops
GNOME
The Wayland session is built into GNOME and it should be an option in your display manager simply by having GNOME installed.
KDE
KDE Plasma requires the non-default plasma-workspace-waylandpackage to be installed. This is often enough for basic functionality, however you are recommended to read the detailed wiki section for KDE on Wayland, especially if you are using an NVIDIA GPU.
Others
Other Wayland compositors of interest may include Sway(a near drop-in replacement for i3) and enlightenment.
Applications
Introduction
GTK3 and Qt 5 applications using the system libraries should default to Wayland automatically. Some that use statically-linked versions of these, or which explicitly disable Wayland support for various reasons (e.g., KeePassXC), will require special flags or environment variables to be set.
Applications using X11 will work fine in Wayland via the Xwayland compatibility layer, however there may be input issues or other bugs introduced. When possible, using an application in its native Wayland mode is preferred.
To support screenshotting, screencasting and screensharing for example in Web Browsers pipewire is required in addition to one of the Desktop specific xdg-desktop-portal packages.
GTK3
The GDK_BACKEND environment variable, when set to 'wayland', will forcibly run a GTK3 application with the Wayland backend. Similarly, setting the environment variable to 'x11' will force it to run with the X11 backend (useful for forcing applications to use Xwayland that have compatibility issues when operating in their native Wayland mode).
Note that some Electron applications (Slack, Element, Discord, etc.) or chromium (861796) may break when setting GDK_BACKENDto 'wayland'.
Qt 5
The qtwayland5 package will install the relevant platform plugin allowing Wayland apps to run natively with Qt.
You are recommended to set the environment variable QT_QPA_PLATFORM to 'wayland;xcb' which will have applications prefer Wayland only use X11 as a fallback. You can, of course, set this to also be specifically either 'wayland' or 'xcb' if you want to force one.
The -platform wayland flag can also be used as a simpler means to force most Qt applications to use the Wayland backend.
SDL2
For games, applications, or other software that uses SDL2 as a toolkit, set the SDL_VIDEODRIVER environment variable to 'wayland'. Note that doing this on a system-wide basis isn't recommended, as many proprietary applications use statically-linked versions of SDL2 that are older and may break when forcing the usage of Wayland.
Display Managers
GDM3
GDM (GNOME Display Manager) will automatically use Wayland when supported, except when using the proprietary NVIDIA driver, in which case it will fall back to X11 due to instability.
To use the X11 backend by default, uncomment the WaylandEnable=falseline in the /etc/gdm3/daemon.conf file.
SDDM
Wayland support for SDDM itself is in progress, currently it uses X11 by default everywhere. SDDM is still capable of starting a Wayland session for a desktop however.
LightDM
There is little hope of LightDM obtaining native Wayland support, however it can still start a Wayland session for a desktop.
Testing Wayland
To test Wayland, you will need to have a compatible compositor installed. A Wayland compositor combines the roles of the X window manager, compositing manager and display server. Most major desktops support Wayland well, but for testing purposes, weston is the reference implementation of the concept.
You can test Weston directly from a regular X session simply by installing the weston package and then running westonin a terminal session. This will start a Wayland window in your regular X session where you can test things.
You can also test GNOME's mutter Wayland compositor directly:
Then further Wayland clients will show up in that window. Try, for example, starting gnome-terminal.
Supported environments
Desktop environments:
- GNOME 3.20+ (Wayland used by default in Debian 10 and newer, older versions use Xorg by default)
KDE Plasma 5.4+ (Xorg is used by default, Wayland requires the plasma-workspace-wayland package to be installed)
- Enlightenment
- Hawaii
Toolkits:
- Qt 5
- GTK+ 3.20+
- Clutter
- SDL 2.0.2+
- EFL
- GLFW 3.2
Window managers:
sway (website, Github project) (Will stop supporting NVidia EGL/closed source driver from 1.0 onwards.)
Fireplace (no Debian package yet)
Partially supported
Emacs: because Emacs is not a real GTK apps, it still talks with X11 and therefore will use XWayland
Vim: similar (819954)
Unsupported
Desktop environments:
Cinnamon: discussed
MATE: planned, source (2014), an update (2019)
XFCE: planned
Toolkits:
FLTK: 984620
Window managers:
i3: FAQ, discussion.
- other window managers unlikely to be supported
Xwayland
For backwards compatibility, any X program will run under Xwayland. Install the xwayland package if it wasn't brought in by your desktop of choice.
If using the Weston compositor add these lines to ~/.config/weston.ini
The security and performance improvements of Wayland are not be obtained with Xwayland.
Troubleshooting
Xresources won't load
This is a known issue. Back in 2015, it was decided that the resources were too slow to load and that was dropped from the main GNOME session, see Redhat's bugzilla for more information.
Workaround: run this by hand or setup something to start it up automatically on session login.
FAQ
Why is Wayland necessary?
Wayland allows better isolation between processes: one window cannot access resources from, or inject keystrokes into, another window.
Wayland also has the potential to be faster, by reducing the amount of code between the processes and the hardware, by delegating lots of things to the processes themselves.
See also the Wayland FAQ for more information.
Does Wayland Server Still Exist Today
Applications can't share information with each other... so how do I copy and paste?
The clipboard should work like normal between X11 and Wayland applications in most sessions, however it's up to the Wayland compositor to negotiate this.
Does Wayland Server Still Exist Now
I'm accustomed to running various programs (e.g. synaptic) as root in my X session. How will this work under Wayland?
(In fact, synaptic was temporarily removed from buster because it didn't work under Wayland.)
There are plans to allow X11 applications running as root to use XWayland but native Wayland applications need to be restructured into a GUI part and a root part.
I run various programs over the network, e.g. through ssh X11 forwarding, or xhost. How will this work under Wayland?
SSH X11 forwarding works like before for X11 applications via XWayland. Native Wayland applications are not forwarded.
I share monitors between systems using x2x. How will this work under Wayland?
Screen sharing with Wayland is in the preliminary stages. Currently, the most progress has been made in Chromium where pipewire and xdg-desktop-portal can be leveraged for screen sharing in WebRTC. With these packages installed, WebRTC PipeWire support must still be enabled in the Chromium flags, as can be found by entering in the address bar: chrome://flags/#enable-webrtc-pipewire-capturer
Further reading
Arch Linux wiki
Wayland homepage
Wayland FAQ
CategoryDesktopEnvironment