Category Archives: Wayland

Wayland Display Server Protocol

Wayfire Ubuntu Packages

After more than a few requests for wayfire deb packages that work on ubuntu, I decided to try creating some. The result is a success. This is how I did it.

First, I started with the latest code. I will cover wayland and wayfire packages. There are others that are required, but these two are different in that wayland packages are already in ubuntu but there are none for wayfire.

For wayland, we will copy the debian directory, containing the interesting files for building a package from upstream, and place it in the upstream code directory.

$ git clone https://git.launchpad.net/ubuntu/+source/wayland wayland-ubuntu
$ git clone https://gitlab.freedesktop.org/wayland/wayland wayland-upstream
$ cp -r wayland-ubuntu/debian wayland-upstream

Next, we want to prepare the environment by installing the build dependencies.

$ sudo apt-get build-dep wayland
$ sudo apt install gcc g++ meson ninja debhelper dh-make

Finally we want to configure and build the packages.

$ dh_auto_configure --buildsystem=meson
$ dpkg-buildpackage -rfakeroot -us -uc -b

This results in the following packages:

libwayland-bin_1.19.90-1_amd64.deb
libwayland-client0_1.19.90-1_amd64.deb
libwayland-cursor0_1.19.90-1_amd64.deb
libwayland-dev_1.19.90-1_amd64.deb
libwayland-egl1_1.19.90-1_amd64.deb
libwayland-egl-backend-dev_1.19.90-1_amd64.deb
libwayland-server0_1.19.90-1_amd64.deb

For wayfire, the process is similar but we need to generate the debian files. Install dependencies manually, by satisfying meson first.

$ git clone https://github.com/WayfireWM/wayfire && cd wayfire
$ dh_make --createorig -p wayfire_0.8.0
$ dh_auto_configure --buildsystem=meson
$ dpkg-buildpackage -rfakeroot -us -uc -b
$ ls ../*.deb
../wayfire_0.8.0-1_amd64.deb

Here is a PPA containing all the packages needed for wayfire on Ubuntu >=20.04. To install wayfire:

$ sudo add-apt-repository ppa:soreau/wayfirewm
$ sudo apt-get update
$ sudo apt install wayfire wayfire-plugins-extra wf-shell wcm xwayland

Launch wayfire by running it from X or tty, or simply logout and select the Wayfire session.
To remove completely:

$ sudo apt install ppa-purge
$ sudo ppa-purge ppa:soreau/wayfirewm

Wayfire

Usually I blog about compiz after a release but I wanted to share something different. There is a C++ wayland/wlroots compositor by Ilia Bozhinov in the works that has many compiz-like features. It’s called Wayfire and it has quite a few bells so far. It functions on a plugin based system much like compiz and the API is fairly nice. I’ve written wcm,  a configuration GUI for wayfire inspired heavily by ccsm. There are videos on the website at wayfire.org you can view to see the basics. It will only work with drivers offering gbm however, which basically means it works with open source drivers. Wayfire and wlroots are very much in development so the bleeding edge may not work but when it does, it’s fire.
General build guide for ubuntu 18.04:

1) Install dependencies from packages.

$ sudo apt install git python3-pip pkg-config libwayland-dev autoconf libtool libffi-dev libxml2-dev libegl1-mesa-dev libgles2-mesa-dev libgbm-dev libinput-dev libxkbcommon-dev libpixman-1-dev xutils-dev xcb-proto python-xcbgen libcairo2-dev libglm-dev libjpeg-dev libgtkmm-3.0-dev xwayland

2) Install meson and ninja.

$ pip3 install meson ninja; . ~/.profile

3) Export prefix, PATH and PKG_CONFIG_PATH variables.

$ export prefix=/opt/wayfire
$ export PATH=$prefix/bin:$PATH
$ export PKG_CONFIG_PATH=$prefix/lib/pkgconfig:$prefix/share/pkgconfig:$prefix/lib/x86_64-linux-gnu/pkgconfig

4) Create the installation directory and change user and group so we can install the software as user. Also create a src directory to hold the source code.

$ sudo mkdir $prefix; sudo chown $USER:$USER $prefix
$ mkdir ~/src; cd ~/src

5) Clone the source we will need.

$ git clone https://gitlab.freedesktop.org/wayland/wayland
$ git clone git://anongit.freedesktop.org/wayland/wayland-protocols
$ git clone git://anongit.freedesktop.org/xcb/libxcb
$ git clone https://github.com/swaywm/wlroots
$ git clone https://github.com/WayfireWM/wayfire
$ git clone https://github.com/WayfireWM/wf-shell
$ git clone https://github.com/WayfireWM/wcm

6) Build the source code.

$ cd ~/src/wayland && ./autogen.sh --prefix=$prefix --disable-documentation && make && make install
$ cd ~/src/wayland-protocols && ./autogen.sh --prefix=$prefix && make && make install
$ cd ~/src/libxcb && ./autogen.sh --prefix=$prefix && make && make install
$ cd ~/src/wlroots && meson build --prefix=$prefix && ninja -C build && ninja -C build install
$ cd ~/src/wayfire && meson build --prefix=$prefix && ninja -C build && ninja -C build install
$ cd ~/src/wf-shell && meson build --prefix=$prefix && ninja -C build && ninja -C build install
$ cd ~/src/wcm && meson build --prefix=$prefix && ninja -C build && ninja -C build install

7) Copy config files in place and modify them a bit.

$ cp ~/src/wayfire/wayfire.ini.default ~/.config/wayfire.ini
$ cp ~/src/wf-shell/wf-shell.ini.example ~/.config/wf-shell.ini
$ sed -i 's/env XDG_CURRENT_DESKTOP=GNOME gnome-control-center/wcm/' ~/.config/wf-shell.ini

Optionally set a background image in ~/.config/wf-shell.ini from your system.

8) Save this script as /usr/local/bin/wayfire.

#!/bin/bash

prefix=/opt/wayfire
log_file=/tmp/wayfire.log

export PATH="$prefix"/bin:$PATH
export XDG_DATA_DIRS="$prefix"/share:$XDG_DATA_DIRS
export GTK_THEME=Adwaita:dark
export GDK_BACKEND=wayland
export QT_QPA_PLATFORM=wayland
export LD_LIBRARY_PATH="$prefix"/lib:"$prefix"/lib/x86_64-linux-gnu/
exec "$prefix"/bin/wayfire "$@" &> "$log_file"

8b) Make it executable.

$ sudo chmod +x /usr/local/bin/wayfire

9) Run it.

$ /usr/local/bin/wayfire

9b) Open an application. Either run a native terminal,

WAYLAND_DISPLAY=wayland-0 GDK_BACKEND=wayland terminator

or an X11 one.

DISPLAY=:1 xterm

10) Optionally switch to tty to use the drm backend. Make sure your user is part of the video group to run as user.

sudo adduser $USER video

11) Optionally create /usr/share/wayland-sessions/wayfire.desktop to login from lightdm.

[Desktop Entry]
Version=1.0
Name=Wayfire Session
Comment=Use this session to run Wayfire as your desktop environment
Exec=/usr/local/bin/wayfire
Type=Application

Firefox nightly should work as a native browser. Ctrl+Alt+Bckspc to log out. Any questions should be asked in #wayfire on irc.freenode.net or an issue filed on github for the relevant component. To remove the compiled packages and source, remove /opt/wayfire/, ~/src/, /usr/local/bin/wayfire and /usr/share/wayland-sessions/wayfire.desktop. Checkout wayfire.org for more information.

Wayland Wobbly Whistles

I found some time and inspiration to resume working toward wobbly wayland surfaces. After making decent progress, it’s time for another blog entry.

Effects such as wobbly windows are argued by some to be a blatant waste of time for both developers and users. However, many still enjoy wobbling their windows despite the controversy. Some power users claim that the mindless wobbling is a welcome brain rest during other tasks. Critics aside, the effect continues to live on in different forms and implementations.

In this iteration, I decided to port the original compiz plugin to wayland surfaces. First, I isolated the code to identify the algorithm inputs and bound the output to a more easily portable format. Then I worked on massaging it into the compositor code, creating a rudimentary plugin API. In the process, the zoom code was also isolated in it’s own plugin. For the moment, plugins aren’t loaded automatically and must be specified in the config file.

Surprisingly, the model positioning code is the most complicated issue because the plugin must render such that the surface position is synced with the compositor when the wobbling cycles are complete. One annoying positioning problem was related to a combination of rotating and resizing but I managed to track down the core issue and fix this case.

The way opaque and blend regions are handled requires duplicate rendering; one with the opaque rbgx shader and another pass for blended rgba. Since wobbly requires additional arbitrary vertices, it’s not really feasible to draw two different regions. For now, it uses the usual rgba shader if the blend region is not empty and the rgbx shader otherwise.

Further plans include writing an interface to talk to the compositor from a GUI and more compiz-like plugins. Check back later for more updates.