Switching to Wayland

This year I bought a new laptop, a Dell XPS 15. I also took this opportunity to try out something new, and fix some screen tearing issues I was annoyed about. Therefore I switched from the i3 window manager to the Sway window manager.

Sway is a drop in replacement for I3, which means my existing i3 configuration still works. It also uses Wayland, a protocol designed to replace X Window System (X11). Wayland aims to be more performant and reduce screen tearing and I can testify for both.

I’m quite happy now, but it took quite some time and sweat to get everything set up. Thus, I’ll leave this blog post for you. I already published how I remapping Capslock to Escape and how to persist audio configuration for bluetooth devices.

Replacing X11 Applications

Turns out a lot of applications were built for X11, and don’t work under Wayland. These had to be replaced.

Autotyping Passwords with Keyboards

Sadly automatically entering a password (the most important features of a Password Manager) did not work in KeepassXC. Starting it under Wayland disables the Global AutoType feature by default. And furthermore, KeepassXC can’t read the window title of a browser that runs under Wayland. Furthermore there is a long ongoing discussion about why it will probably never be supported. This makes KeepassXC unusable for me. But… thankfully, there is a workaround.

Many desktop environments already use Wayland by default, however since X11 was a bit bloated, it’s hard to completely replace it. That’s my you often see Wayland and X11 running in parallel. So does Sway, it uses Xwayland.

To be able to read the browsers window title in keepass, we need to start Firefox under Xwayland. We can do this by setting the MOZ_ENABLE_WAYLAND environment variable.

MOZ_ENABLE_WAYLAND=0 firefox

And of course, do the same for KeepassXC

QT_QPA_PLATFORM=xcb keepassxc

I3 Specific Applications

Sway thankfully ships with some sane alternatives to common applications used with i3.

The i3 lock screen i3lock was replaced by swaylock and swayidle.

nitrogen for setting a desktop background can now be done with a single config line output * bg ~/wallpaper.png fill.

Automatically dimming your screen brightness with redshift is supported out of the box.

Hiding the Mouse Cursor when Typing

Under X I used xbanish to hide my mouse cursor when typing. Sway even has this configured by default with this configuration

# hide cursor while typing
seat * hide_cursor when-typing enable

Taking Screenshots

Previously I used scrot inside scripts to be able to take screenshots and scan QR codes, run OCR on some display area or translate text.

There is a nice alternative though called grim. Sway already shipps it, and slurp that allows you to select a rectangle on your screen. Additionally there’s swappy which allows you to edit an image and annotate it.

# screenshot area on screen and open image editor
grim -g "$(slurp)" - | swappy -f -
 
# screenshot area on screen and run OCR on it
grim -g "$(slurp)" - | tesseract - - | wl-copy

Quite useful as an alias too.


Some other useful resources I found helpful when switching