DEV Community

Jeansen
Jeansen

Posted on • Edited on

From X11 to Wayland

Now it is official. Gnome will remove X11 support until version 50!. I always stayed with X11 because it simply felt more stable than Wayland. But now, it is final. X11 will be no more in Gnome!

Aside from special features only available in X11, e.g. running X11 applications from a remote host on a local machine though SSH, Gnome works the same way as it does on X11.

What I truly miss is the xkill command which allows me to kill any (stuck) X11 app quickly and easily. This was the ultimate BFG like kill -9 but for X11 applications.

Other things I used on X11 were global hotkeys to remap any key combinations in any application to my liking and a lightweight and minimalistic Dock. For global hotkeys I used Autokey and for the dock I used Plank. Unfortunately both of these applications are X11 only.

What follows are my (finally) working adoptions and workarounds to get Gnome on Wayland working with global application hotkeys and Plank.

Plank

Plank is my favorite lightweight and minimalistic Dock. Unfortunately, it does not natively support Wayland. It is X11 only. But, it does work with some help and using the XWayland wrapper. First, make sure you have XWayland installed. In Debian it is as simple as running sudo apt install xwayland. This is a little extra package that makes it possible to run X11 applications with Wayland. Second, you must overrule Plank and bamfdaeomon in detecting their environment.

For bamfdaemon.service create the file /usr/lib/systemd/user/bamfdaemon.service.d/override.conf and put the following override in it:

[Service]
Environment="XDG_SESSION_TYPE=x11"
Environment="GDK_BACKEND=x11"
Enter fullscreen mode Exit fullscreen mode

Afterwards, reload the service with sudo systemctl daemon-reload

For Plank I wrote a little Systemd script:

[Unit]
Description=Plank Dock
After=graphical-session.target

[Service]
Environment="XDG_SESSION_TYPE=x11"
Environment="GDK_BACKEND=x11"
ExecStart=/usr/bin/plank
Restart=on-failure
RestartSec=5s

[Install]
WantedBy=default.target
Enter fullscreen mode Exit fullscreen mode

Put the above script in ~/.config/systemd/user/plank.service and enable it with systemctl --user enable plank.service

Now, whenever I boot into Gnome, Plank comes up automatically and pinning applications in the dock, including the indicator of already running (and pinned) applications, works as expected.

Autokey

Another X11-only application I do not want to miss is Autokey. You can make it run under Wayland like this:

env -u WAYLAND_DISPLAY autokey &
Enter fullscreen mode Exit fullscreen mode

One caveat is that Autokey then only intercepts X11 applications. For instance, you could run Google Chrome like this on Wayland and make it compatible with Autokey again:

google-chrome-stable --enable-features=VaapiVideoDecoder --ozone-platform=x11 --use-gl=egl &
Enter fullscreen mode Exit fullscreen mode

Make sure you have the necessary drivers installed. On Debian the minimum (with all its dependencies) are:

  • libva-drm2
  • libva-wayland2
  • libva-x11-2

Running Google Chrome this way allowed me to use Autokey the same way I used it on X11. But don't expect the XWayland wrapper to behave exactly as X11. It is a wrapper and like every wrapper it has its flaws and performance issues!

xremap

Recently I found a better solution and replaced Autokey with the Help of xremap. Following the documentation I had to:

  • compile and install xremap
    cargo install xremap --features gnome

  • add a udev rule to run xremap without sudo privileges

sudo gpasswd -a YOUR_USER input
echo 'KERNEL=="uinput", GROUP="input", TAG+="uaccess", MODE:="0660", OPTIONS+="static_node=uinput"' | sudo tee /etc/udev/rules.d/99-input.rules
Enter fullscreen mode Exit fullscreen mode
  • install the accompanying Gnome Shell Extension

  • and create a configuration file in ~/.config/xremap/config.yml, for example:

keymap:
  - name: Brave Browser
    application:
      only: brave-browser
    remap:
      C-d: C-w
      C-Shift-d: C-Shift-t
Enter fullscreen mode Exit fullscreen mode

Finally, I created a Systemd service so xremap would also start as soon my Gnome sessions is active:

[Unit]
Description=Xremap
After=default.target

[Service]
ExecStart=%h/.cargo/bin/xremap --watch=device %h/.config/xremap/config.yml
Restart=on-failure
RestartSec=3
StandardOutput=journal
StandardError=journal

[Install]
WantedBy=graphical-session.target
Enter fullscreen mode Exit fullscreen mode

As with the Plank service, put the above script in ~/.config/systemd/user/xremap.service and enable it with systemctl --user enable xremap.service

With this setup in place I am now back on track running Gnome (but on Wayland) with my beloved Plank dock and global application hotkeys enabled. Taking the above little configuration file for xremap I can now run Brave and close any tab with ctrl-d instead of ctrl-w or reopen an accidentally closed tab with ctrl-shift-d in place of ctrl-shift-t.

Top comments (0)