Wayland is intended to be a simpler and modern replacement for X display server.
"Wayland is a protocol for a compositor to talk to its clients as well as a C library implementation of that protocol. The compositor can be a standalone display server running on Linux kernel modesetting and evdev input devices, an X application, or a wayland client itself. The clients can be traditional applications, X servers (rootless or fullscreen) or other display servers." Where possible, Wayland reuses existing drivers and infrastructure, such as the DRI drivers, the kernel side GEM scheduler and kernel mode setting.
Several packages are aware of the global
wayland USE flag.
USE flags for dev-libs/wayland Wayland protocol libraries
||Add extra documentation (API, Javadoc, etc). It is recommended to enable per package instead of globally|
emerge --ask dev-libs/wayland
Wayland is completely supported in GTK 3.22. Nevertheless, when porting application in general two issues must be considered:
- Ensure that your application uses gtk+-3.0 for its pkg-config request.
- All calls to the gdk_x11_ namespace and raw Xlib calls must be wrapped in build-time and run-time backend checks.
More details including plans and progress can be found on the GNOME wiki.
For Qt an additional package called dev-qt/qtwayland is required. In the Qt Wiki it says: "QtWayland is a Qt 5 module that wraps the functionality of Wayland. QtWayland is separated into a client and server side. The client side is the wayland platform plugin, and provides a way to run Qt applications as Wayland clients. The server side is the QtCompositor API, and allows users to write their own Wayland compositors."
GTK 3.x and Qt support Wayland. Unfortunately most applications still require the X server. Several scenarios are possible to get them working:
- Porting the application by rewriting the components with X.org dependencies such that they work also for wayland. Cf. Wayland-Ports. Other examples are mpv which is a video player based on MPlayer/mplayer2 or the minimalist web-client xombrero, midori and epiphany also have full support for wayland. GNOME and KDE are expected to be ported to it.
- Xwayland is an X server that operates as a Wayland client for running legacy X11 applications on Wayland. With Xwayland configured, the user will be able to run many X11 applications as usual. See the Wayland docs, Wikipedia, and man XWayland.
Starting an X11 only app on Wayland
Sometimes it is necessary to start an X11 only application on Wayland.
When the app uses the GTK toolkit, or when starting an X11 only app from Gnome 3, simply adjust the GDK_BACKEND environment variable as appropriate:
To check the current value:
printenv | grep -i GDK_BACKEND
To temporarily set the value to X11 and start the app, for this example starting the binary Tor browser:
Running Google Chrome or Chromium in Wayland mode
In order to run Google Chrome or Chromium in native Wayland mode, it should be started with the arguments
It might be necessary that the user is in the video and additionally in the graphics group.
Running Wayland or X11 applications as a different user
For a pure wayland application, the procedure is relatively simple:
1. Make sure that the new user has at least the permissions rx to the directory $GDK_RUNTIME_DIR (of the logged-in user), the permissions rwx to the socket $WAYLAND_DISPLAY in this directory, and the the permissions rw to the lockfile $WAYLAND_DISPLAY in this directory. If the filesystem supports acls and virtual/acl is installed, this can be done as the original user with the commands
setfacl -m NEW_USERNAME:r-x -- "$GDK_RUNTIME_DIR"
setfacl -m NEW_USERNAME:rwx -- "$GDK_RUNTIME_DIR/$WAYLAND_DISPLAY"
setfacl -m NEW_USERNAME:rw -- "$GDK_RUNTIME_DIRk/$WAYLAND_DISPLAY.lock"
2. As the new user, export the path to the original user's socket as WAYLAND_DISPLAY:
Both is done by default if app-admin/sudox from the mv overlay is used to change the user permissions.
For an X11 application, things are more complicated: As for native X11, you have to export the MIT cookies. This can be done by using app-admin/sudox to change the user or by copying or giving access to the ~/.Xauthority file.
Unfortunately, many compositors do not start Xwayland with support for cookies: Depending on the compositor, it might be necessary to generate the ~/.Xauthority file manually on startup and to run Xwayland with -auth ~/.Xauthority as the first option (after the display name).
The already mentioned app-admin/sudox provides corresponding startup scripts and desktop files for wayfire.
- Wayland compositor
- Xorg — an open source implementation of the X Window System.
- Sakaki's EFI Install Guide — includes a tutorial-style chapter covering the installation of GNOME over Wayland (systemd version, OpenRC version).
- https://www.linux.com/news/what-why-and-how-wayland-and-weston-linux - A Linux.com article explaining Wayland (and Weston).