Dream Nebula | [home] [contact] [blog]

2023-07-18

Wayland is great, actually

Yeah. I switched to Wayland.

After discussing with some randos online about Wayland being better than X11 in terms of security, I remembered about its existence. I was using dwm, and although it does have lots of flaws1, I still think it’s the best window manager in the X11 world if you can get past its bad aspects. Now, after trying sway, dwl, hikari, I ended up choosing labwc, and today I wanna talk about how amazing it has been.

For the record, as of today, labwc is based on the wlroots compositor library, so my experience might not be the same as someone who uses compositors based on weston, GNOME’s or KDE’s compositors, swc, etc.

Everything works, surprisingly

One thing you will certainly find in imageboards and fringe tech communities is that Wayland doesn’t work, it crashes, it explodes, blah blah blah. Well, my terminal (foot) works, my web browser (firefox) works, programs running under XWayland work, everything works. So yes, folks, Wayland is more than ready for daily desktop usage, if you were still wondering. Sure, you still need to set a couple of environment variables here and there, but that’s because most Linux programs assume you’re using X11, like Firefox, and GTK and Qt programs. Those things are trivial, though, if you have customized your shell configs before. Here are the ones I have set in my .bash_profile:

export GDK_BACKEND=Wayland
export MOZ_ENABLE_WAYLAND=1
export QT_QPA_PLATFORM=Wayland-egl
export SDL_VIDEODRIVER=Wayland
export XCURSOR_SIZE=$(gsettings get org.gnome.desktop.interface cursor-size)
export XCURSOR_THEME=$(gsettings get org.gnome.desktop.interface cursor-theme)
export XDG_CURRENT_DESKTOP=sway
export XKB_DEFAULT_LAYOUT=us

(The $XDG_CURRENT_DESKTOP variable is set to “sway” because most programs don’t know what to do when it’s set to something else. Labwc is based on wlroots, just like sway, so it shouldn’t be a problem.)

Clipboards are waaaaay simpler

Who the fuck decided that it would be a good idea to have three different clipboard registers? I don’t know, but apparently the people that made X11 thought so. Here in Wayland, you either wl-copy, or you wl-paste. No need to have to juggle between more than one clipboard, and a spec that’s not even consistent (terminals and things selected with your mouse typically use the “primary” selection, while most graphical programs take stuff from the “clipboard” selection when you press ctrl-v2).

I have a couple of scripts that pipe things to my clipboard, like selecting something inside tmux, grabbing an emoji from a big file full of them, etc. For a while, I would literally do…

$ echo something i want in my clipboard | xclip -sel p
$ xclip -sel p -o | xclip -sel clip

inside of my scripts, until I found a way to use the “clipboard” selection inside my terminal. But, if i wanted to copy a line inside vim and pass it to my clipboard, I would still have to specify the “clipboard” selection, like this:

:.!xclip -sel clip

This might not seem a big deal at first, because I could just only use that specific command, but from a design perspective, why would you need multiple clipboards that don’t talk to each other at all? It’s much better to have only one register, and use a clipboard managing program to copy and take note of multiple things at the same time, if needed.

wl-copy and wl-paste are shorter and easier to understand.

Update: Apparently there’s a primary-selection-unstable-v1 protocol for, you know, primary selections, or selections you do with your mouse. Personally I don’t care about it, I don’t think it’s a good thing, but if you do, it’s there. You can take stuff from the primary selection with wl-clipboard by specifying it with the --primary option, which I think is better than having to specify a register every time.

Taking screenshots is the most beautiful thing

I know this is silly, but I just wanna talk about how you can combine slurp, which is a program that allows you to select a region of your screen and prints some coordinates, with grim, which is basically the Wayland equivalent of scrot. This is a perfect example of the UNIX philosophy at play, specifically of chaining programs together, and each program doing only one thing and doing it well.

Alright, wanna take a screenshot of your whole screen? Well, you can just run grim, but what about only a portion of your screen? Simple!

$ grim -g "$(slurp)"

-g specifies the “region to capture, in layout coordinates”, which is what slurp gives us. Pretty cool, right? No need to use big programs like flameshot.

“Wait”, you might say. “Flameshot allows for copying the screenshot to the clipboard!” Well, haven’t I just talked about wl-clipboard? You can use that, too!

$ grim -g "$(slurp)" - | wl-copy

Yep, simply tell grim to send the PNG goobly goo to stdout, then pipe it to wl-copy. You can remove the pipe to see what the goobly goo looks like.

Because of that hifen option, you can save a screenshot to a file in this funny way:

$ grim - > picture.png

(but don’t. grim already has a -o option to specify a file name.)

Anyway, I just love these UNIX-y programs that can be combined with everything else in your system. As someone who loves making shell scripts, that’s like a new toy in my collection.

Closing thoughts and opinions

I myself had lots of misconceptions regarding Wayland. I called it “soy”, “zoomer-tier”, “sketchy”, things like that. Just because something is modern, doesn’t mean it’s bad. The same thing applies to old things, too, but X11 has showed more than once that its end is nigh. If you’re reading this, and think that Wayland is worse than X11 for whatever reason, read the following article. It talks about some of X’s shortcomings (some being silly as fuck), and how Wayland solves them.

This was written in 2013, so a lot of the things that they say that are “work-in-progress” are either ready for normal usage, or very close to being that.

https://www.phoronix.com/review/x_Wayland_situation/

X11 is like a computer virus, in my view, but an evil one. It made us get used to poorly maintained software, that only exist to preserve an abstract “legacy”. There are lots of other great legacies that are worth preserving, like Linux’s, Vi’s, git’s, *BSD’s, but those aren’t worthy legacies just because they are legacies, but because they are great, and the people working on them wanted and made them worthy ones. X11, meaning the version number 11 of X’s protocol, was published in 1987. Nineteen eighty seven. It only went through “revisions” since then. There’s no way that X11 is suited for today’s computing without either adding cruft after cruft to its code (which is what its devs did), or rewriting everything. Does anyone wanna rewrite X from scratch…? Anyone? Oh well…

You don’t need to accept X11, you don’t need to put up with its bullshit. X11 is old and a lost cause, its developers know that it’s old and a lost cause, and people who say otherwise are either lying to themselves, or don’t know enough about reality. You cannot defend X11 in today’s age. Xorg Server (the standard X11 implementation) is bloated and full of old code that no one knows how it’s still there. I don’t know about you, but I’m not okay with that.

And no, X12 is not happening. Wayland has already made a lot of progress, and there’s no need in starting from scratch when there’s already a great project like Wayland going strong. I truly believe that Wayland is, or at the very least should be the future of the Linux desktop, which is part of why I’m staying with it.

Honestly, deep inside I have always liked Wayland, I just needed a little push in the right direction to fully commit to it.

EDIT: Another thing I wanted to add:

I see people everywhere talking about how Wayland is lacking certain features, is immature, will never have as many features as X, etc. The key differential is that at least Wayland has a comprehensible codebase, making the work of patching and contributing code much easier than in Xorg/X11. I know not every Wayland user has experience with C and wants to learn the technical details about their favorite compositor, but allowing and facilitating cooperation by not being a bloated mess is also a very important aspect of the whole ecosystem.

Also, at least for wlroots, there’s an official “minimum viable product” called tinywl, which is amazing for someone like me that is just starting out with wlroots programming.

If Xorg lacked features, most people would just cry, basically :)


  1. All of these apply to all of suckless’ programs. 

    1. Minimalist brainrot;
    2. Having to fuck with source code patches and external tools to get basic functionality;
    3. Being unable to update it without potentially losing functionality because of the above, since the suckless devs don’t maintain the patches themselves because of 1;
  2. There’s also the “secondary” selection, but I have never heard of a program that uses it.