mckinley.cc Home Blog Notes Twtxt

Making the jump from Xorg to Wayland

April 23rd, 2022

Well, I've done it. I've traversed the mountains of config files and the seas of error messages. I've fought the mighty dragon Xorg, and reduced him to a house pet in a cage, only to be wheeled out when I wish to be entertained. I have... switched to Wayland.

Names of programs formatted as code quotes are the names of packages in the Arch Linux repositories. AUR packages have an AUR next to their name. I use Arch, btw.

Jokes aside, it was much easier than I expected it to be. It all started a little while ago, when the "TearFree" option in xorg.conf stopped working on my machine. I can't explain why it stopped working, but it was starting to get to me. The tearing was much less noticeable when smooth scrolling was turned off in Librewolf, and I could almost ignore it when watching video, but it annoys me when I know something needs to be fixed.

The next step in eliminating screen tearing, after TearFree, is usually a compositor. It was easy enough to download picom and add it to my .xinitrc with the necessary options to enable vsync. It did fix the screen tearing, but it came with a bunch of terrible visual effects. Shadows, transparency, windows fading in and out. I'm not one for that kind of "eye candy", so I spent far too much time digging through man pages and wiki articles until I had a big long line of command line options that would negate most of the effects. It still bugged me, because I knew it was probably using more of my system resources to render shadows with 0 opacity and window fade effects that happen instantly. Other, more minimal options didn't seem to have any vsync features, so negating the effects in Picom was the best I could come up with. Finally, when I hovered over a link in Librewolf and saw a transparent tooltip, I decided it was time to go nuclear.

I have used i3wm on Xorg for years, so the logical choice for Wayland was Sway, a drop-in replacement for i3wm. Before I began my journey, I went to see the Oracle, also known as the Arch Wiki. I kept reading and reading, knowing it had to be more difficult than running doas pacman -S sway and typing sway in a tty. I was wrong. In seconds, I had Sway running in tty2 and i3wm running in tty1. Sway used my existing i3 configuration automatically, and my hotkeys even worked, but I figured it would be best to make my own config file.

The process was simple enough. I left most things default, as I did with i3. I realized I shouldn't use XTerm as a terminal emulator, so I installed the recommended foot terminal. When I got to the bar section, I realized that it was updating the time not based on when it changed, but on a pre-defined timer. I couldn't have that, so I switched to an alternative called waybar (repo) by replacing the bar section of the Sway configuration file with bar swaybar_command waybar.

The default Waybar configuration is horrendously ugly. There are entirely too many colors, and there is simply too much packed into the bar. I only have 1600 pixels to work with. I made my own, based on the minimal configuration example on the wiki. I like it better than the default i3 bar, which I've used for years. I never bothered to customize it because the defaults worked well enough.

Once I had the system looking the way I want it, I decided to disable XWayland, the Xorg compatibility layer, to see which programs work out of the box in Wayland. To my surprise, dmenu, which I used primarily as a program launcher, didn't work despite being part of the default Sway configuration. I replaced it with a Wayland-supporting alternative called bemenu that I customized to fit in with the rest of the desktop using some command line options.

Moving on to user applications, everything I tried based on Qt5 or GTK3 worked okay with one major exception: Audacious, my music player of choice. It's based on Qt5 by default with GTK2 as a fallback, and while it opened and played music, the different components wouldn't snap together when using the compact view. Usually, if you put the equalizer and the playlist view together with the player window, they "snap" together and you can move them around as one. Snapping wouldn't work even when using XWayland. I tried the GTK3 version (audacious-gtk3AUR) but that just made it worse. Windows still wouldn't snap together and, when not using XWayland, there was a Sway title bar and window border on each component.

Here are some other graphical programs I'd like to mention:

All in all, it was a pretty soft landing. Here's what it looks like all together. I like the way it looks. At the very least it fixed my screen tearing.

P.S. Here's a bonus tech tip for you. If you want to force a program to run in XWayland, run it from the command line like this: env -u WAYLAND_DISPLAY (program name).