Wayland on OpenBSD

Introduction

These are my notes from experimenting with building Wayland bits on OpenBSD during g2k23 in Tallinn… Thanks to the OpenBSD foundation for organizing this event.

This is still far from a complete running system as there are many issues on the road, but it’s a good start and it shows that it’s definatly not impossible to get Wayland running on OpenBSD.

Updated to reflect that all of this in now a work in progress set of ports

Disclaimers

General ideas

All this works on top of existing Xenocara and ports.

Available ports

All needed ports are available on this repository.
This can be cloned into mystuff to build and install the packages over and existing ports tree.

cd /usr/ports
git clone https://gitlab.tetaneutral.net/mherrb/wl-ports.git mystuff
cd mystuff/wayland/sway
make install

sysutils/seatd

The original project in on Source Hut

The OpenBSD port is very minimal but enough for now. TODO: make it more complete WRT VT switching, using fbtab and some sort of session management.

devel/libinput-openbsd

This is the version from mpi@, patched@ by radowski, plus extra udev code from me.
I’ve now added proper events translation (for mouse buttons and keyboard) so that the input works in a usable way in Wayland.

sysutils/libevdev-openbsd

This is a stripped-down version of libevdev, providing just the few functions to handle name to symbol conversions that are used by most Wayland applications.

sysutils/libdisplay-info and graphics/libliftoff

Those two small helper libraries build of of the box on OpenBSD. I’ve made ports for them in my xenoports tree, or they can be built from gitlab:

wayland/xwayland

It’s a straightforward port of the upstream release.

wayland/wlroots

A version of wlroots that has been patched for OpenBSD. The wscons backend code can dropped for now. I’m not sure if it will ever be possible to have Wayland applications running without libinput (but that’s the goal of this backend).

wayland/havoc

Havoc is the simplest terminal emulator application for Wayland that I could find and that builds on OpenBSD with minimal changes.

wayland/sway

Sway is a tiled Wayland compositor, compatible with i3, ported to OpenBSD

swayimg

TODO : port

An image viewer for Wayland that builds on OpenBSD without patches \o/

git clone https://github.com/artemsen/swayimg.git
cd swayimg 
meson setup build
ninja -C build
doas -C build ninja install

Default cursor theme

Wayland doesn’t provide cursors by itself. So one needs to install the gnome-icon-theme package or any other package providing a default theme.
Because of the cursor path mentionned above, link /usr/local/share/icons to ~/.icons for now to get cursors.

Note: swaybar used to segfault if it’s missing a cursor, it should be fixed in the current port

Fonts

Wayland is using fontconfig. So it can use any fonts installed via pkg_add swaybar expects the terminus font to be available.

Running Wayland

One needs to set a number of environment variables. The following script (runwl) helps:

#! /bin/ksh
export XDG_RUNTIME_DIR=/tmp 
export WAYLAND_DISPLAY=wayland-0
exec $*

X Applications

Sway starts Xwayland automatically if an application needs X

It can also be started manually, but not in rootless mode (this is a Wayland security feature). X applications work in the Xwaylan in windowed mode, but OpenGL X applications crash (probably because of mismatched Mesa versions in my builds FIXME

More work to do

Gtk applications

Simple patches allows to build gtk+3 and gtk+4 with wayland support enabled. gtk3-demo works, built against the patched version.

Note that both emacs and mozilla-firefox work, but still use Xwayland. The ports need some plist and lib-depends patches once wayland support is enabled in gtk+3/4.

So far gtk4-demos fails to start, it still tries to connect to an X serer and segfault. FIXME

Qt applications

Qt 5 and 6 are normally built with Wayland support. I tried keepassxc(1) (Qt5) which could’nt connect to the compositor. qt6/qtbase doesn’t build on my system from some reason. FIXME

<uchar.h> and char32_t

A number of Wayland applications use UTF-32 internally and require support for the above that it not (yet) available on OpenBSD. TODO: one implementation exists in DragonFlyBSD.
Thay would probably unlock foot and others.

swaylock

To get a screen locker, swaylock needs to be tought about BSD auth to replace PAM.

Pledge and Unveil

None of the above currenty implement pledge() or unveil() support, nor any other from of sandboxing afaict. This could be looked at at some point.

Known issues


Last modified: 2023-07-16T19:21:00