Published on bearblog

Wayland is Almost There

Wayland is a thing. It’s the future. If you listen to the hype then you’ll hear about all the different ways it’s better than X and how X is so outdated and old and… nasty.

And that’s true. X is old, and X is nasty, especially when you stray outside the happy path and get stuck in the customisation quicksand or the configuration quagmire.

But there’s something else true: X works. And unless you want to get stuck in that quagmire, unless you delve deep into the architecture and work up an emotion, unless you have a ideological opposition to what’s old, you don’t need to worry about any of that. Install your favourite distribution, pick your preferred desktop environment (please not GNOME3 though); things will just work.

Installing Wayland

But the mind is as the mind does, and the hype does wear you down after a while. You can have too much of a good thing. Comfort is normalised, things can’t just be OK, there must be something better out there… So it goes that way, I’ll switch to wayland then. At least to try it out, for a week. That’ll be fine. Everybody says it’s easy. What could go wrong.

Back to reality for a second, and for a bit of context: just before the government mandated period of home-working my main development computer was running more smoothly than it ever had before. I had a big 4K monitor, and one of those ubiquitous little old Dell monitors (to keep up on those slack distractions); I had a two-generations-old AMD graphics card with the open source AMD driver, and I had TearFree enabled so unneccessitating the wrangling of X and vsync. I had the big monitor with fractional scaling and the little one just running at native resolution. I had i3 set up and I had the keybinds ingrained into my muscle memory (just about). I had a compose key!1 I had found a set of applications that worked well and suited my desktop lifestyle! Life was a dream!

But the world being the way it is, Crown Disease broke out and now I’m stuck with a 1080p monitor, and a rather old nVidia graphics card, and the video tearing is making my eyes water. So, wayland it is then. That extra frame of latency is a fair tradeoff for fixing the tearing. And sway exists2, and it’s supposedly a drop-in replacement for i3.

So, I did what was suggested:

sudo apt-get install sway
mkdir ~/.config/sway
cp ~/.config/i3/config ~/.config/sway/config

First impressions, this downloaded quickly! That’s a good sign at least, maybe it isn’t bloated like all modern software development seems to encourage.

And so I foolishly followed the debian migration guide and copied this into my config file

input * xkb_layout "us,de,ru"
input * xkb_variant "colemak,,typewriter"
input * xkb_options "grp:win_space_toggle"
input "MANUFACTURER1 Keyboard" xkb_model "pc101"
input "MANUFACTURER2 Keyboard" xkb_model "jp106"

And then I tried logging out and back in again, this time with sway rather than i3. I was presented with a wonderful black screen, and half a second later unceremoniously dumped back on lightdm again. Something had failed. I wasn’t ready to give up at the first hurdle, so jumped on over to a text terminal, Ctrl-Alt-F1, logged in and tried a second time. A helpful error message, telling me that I can’t use the nVidia proprietary driver. That’s not unexpected, so time to nuke it from orbit:

sudo apt-get purge '^nvidia-.*'
sudo apt-get autoremove

Nice bonus: away goes DKMS, and slow kernel upgrades. And the basic text terminal looks sharp and full-res, not the fuzzy mess it was before. Makes me wonder why I even installed this piece of junk in the first place. But I’m definitely buying AMD next time… Anyway, back to the coal face:

One sway and it’s away. I was in! That happiness only lasted about a single second though, because I realised that I was completely unable to do anything in this new desktop environment. None of my keybinds worked, I couldn’t even find the way to get me out!

So I took my pick of recovery options. Back at the terminal, I realised a likely suspect for this problem. The keyboard layout must be wrong. The debian migration guide has suggested that the most common keyboard layout was colemak. I didn’t even recognise it as the name of a keyboard layout initially, unusual as it is. Why whatever debian developer writing that guide chose it as an example, I don’t know. Colemak… really? Anyway, I RTFMd (man 5 sway-input)3, and worked out a more sensible input command:

input type:keyboard {
    xkb_model pc105
    xkb_layout gb
    xkb_variant extd
    xkb_options compose:ralt
}

So it’s sway and away for the second time. I’m in for real this time. And I had my compose key back, without any hassle at all. It’s starting to feel good!

I had my two screens, and the left was on the left and the right on the right, and I could move the mouse between them! And I could open up kitty, and it worked as it should have done. Score 2 for wayland! Next thing, down come my fingers on the keyboard, the keys are pressed… and dmenu does not appear. Oh. Next up is firefox. Nothing there either. claws? No. Oh dear.

Maybe wayland adoption isn’t as far along as I had heard. It turns out Firefox does have support for Wayland, but it’s not a stable feature yet. dmenu I could replace with wofi. Similarly i3lock can be replaced by swaylock. There’s no substitution (nor any apparent development effort in terms of wayland adoption) for claws-mail though.

So you really can’t just use wayland on its own. It’s not realistic, there are too many applications that rely on X in one way or another. And I don’t think it will be realistic for quite some time yet, no matter what the wayland boosters say. Luckily there is a solution, and it’s just as simple to install as the rest of wayland/sway:

sudo apt-get install xwayland

That, plus a restart is all it takes. Suddenly all my applications work again. I haven’t been able to detect any issues using applications routed through it, so as far as I can tell xwayland has no downsides beyond being just another bit of software to install.

Can Sway replace Xrandr?

Even though I won’t be needing to change display settings regularly with this old desktop, I still decided to try out hotplugging the displays and moving things around. Through the limited set of challenges I tested it with, sway seems to behave fairly logically, albeit you have to control everything yourself with swaymsg input ....

When I tried toggling a display off then on again, my workspaces all shuffled over to the active display, but to my great surprise as soon as the disabled display blinked into life again they were off, back to whence they came! This is very nice QOL improvement compared to what I had before with i3 and Xrandr - having to move the workspaces back to where they should be manually is a pain.

Unfortunately sway doesn’t support display mirroring, or any way to decouple outputs from the logical workspaces, to split one window across multiple montitors. This isn’t a feature I need on my desktop, but it’s nice to have this stuff (or the capability at least) if I were to install wayland on my laptop. There’s an issue open on GitHub although it has the usual affliction: lots of activity but nobody who can be bothered to do the work and submit a patch.

And if I ever get tired of doing the manual work setting up new displays, it looks like kanshi will be there to help.

I didn’t try messing around with HighDPI or backlight control, because this computer just doesn’t have the hardware to support that kind of experiment. Maybe it’ll turn out those are impossible to do if I install sway on compatible hardware, but that remains to be seen!

Impressions

After using my new DE for a few days, I feel I’m competent to give my initial judgement: It’s OK. That’s it! wayland+sway is a combination that works; it’s nothing groundbreaking, it hasn’t told me the winning lottery numbers or finished off all those projects at the top of my to-do list but it works and that’s all that matters really. It’s a bit nicer around the edges than X+i3, and with a little bit more maturation and new features I would have no qualms recommending sway over i3 as the best choice of desktop environment.

My eyes are no longer watering at the thought of display tearing, so the original objective has been satisifed at least, but in terms of the performance impact of compositing I can’t say I really noticed any difference. Probably everything else is so slow that it doesn’t make much difference. Either that or I got used to the difference immediately. Even the mouse cursor latency seems just as good as before.

The performance impact I did notice though was starting up a new kitty instance. Somehow it seems just ever so slightly slower to start up, so the first character or two of the command I was about to type in got cut off. Maybe I’m was just imaginging it, since I got used to the new latency after the first day anyhow.

So I’m going to keep using wayland and sway, unless some big show-stopping issue comes up; and when the pandemic-panic has reduced I will try it on my other computers as well. It’s nothing earth-shattering, but it wasn’t a pain to set up, and it the meat and potatoes of it seem just as good as X.

Niggling Issues

That said, there were still a few outstanding problems I discovered in the first few days, some of which I managed to fix or work around, and others I just couldn’t be bothered to do anything about, since they’re so minor.

One was that my monitors wouldn’t go to sleep when I locked my computer. The documentation was helpful once again and a solution was soon at hand, I had a new lock-script:

#!/bin/sh
revert() {
    killall swayidle
}
trap revert HUP INT TERM
swayidle -w \
    timeout 5 'swaymsg "output * dpms off"' \
    resume 'swaymsg "output * dpms on"' &
swaylock
revert

Admittedly it’s a bit ugly to spawn a new idle daemon and kill each time the screen is locked, but I had to do a similar thing with X as well, so at least it’s not gotten any worse with sway!

My scroll-wheeling speed also seemed to have gone down a little bit, so I tried increasing it. Now I can scroll 1.2 times faster!

input type:pointer scroll_factor 1.2 

scrolling inside kitty was still rather too slow, but I realised quite quickly that all I needed was a small tweak to kitty.conf:

touch_scroll_multiplier 6.0

Apparently wayland is handled as a ‘touch’ device inside kitty and does high-precision scrolling so it needs to be configured seperately.

Another issue resolved not to resolve itself: although my left screen was correctly placed on the left, and the right similarly on the right, and moving the mouse between the two worked as expected; the left screen was workspace number 2 and the right number 1. I like my workspaces to increase from left->right and as far as I can tell I can’t make this happen without lots of manual work on each boot.

lightdm still doesn’t work either, and I can’t be bothered to do anything about that, so I have just switched it off; it’s actually a bit nicer starting my DE manually. It would be nice to know why though, since lightdm and sway are at least notionally compatible with each other.

TL;DR

  • wayland works
  • it’s not perfect, xwayland is necessary, but does it matter?
  • sway is everything good about i3, just better
  • nVidia sucks
  • compositing delay isn’t that bad when everything else is slow anyway

Postnote

One thing I haven’t mentioned is network transparency, and that’s because it’s not a display server feature I have ever used, or ever intend to use. I don’t understand why anybody makes a fuss about it. I can only put it down to display server fanboyism - it’s just completely irrelevant to the actual issues!

Footnotes

  1. If you don’t have a compose key, you should get one. Is that right-alt doing anything useful on your keyboard? Make it a compose key instead and type special characters intuitively. It’s such an obvious feature that I can’t understand why it isn’t supported on any of the major Operating Systems (at least by default, thankfully it’s easy to enable on Linux). 

  2. Incidentally, the author of sway, SirCmpwn is a 100x programmer if there ever was one, the amount of software I use everyday he has written is rather impressive. And while some of his work is unconventional, it’s so much better for it. If you’re not a sourcehut subscriber, you should be. 

  3. The documentation manual-pages for sway are excellent. I was able to find exactly the information I needed without wading through endless junk like I’m used to in manpages. If you want to install sway yourself and get stuck on any of the configuration, look at the manual first and you might be pleasantly surprised. 

Comments

No comments yet!

To leave a comment, please send it via email here. Comments are licensed CC-BY as with the rest of the site. Your sender name and email address will be published along with the comment, unless you tell me not to.


Articles from other blogs I follow

NaNoWriMo - An Introduction and Chapter 1: There Are Nine Million Autonomous Bicycles In Beijing

Every year since 2009, I've taken part in NaBloPoMo - National Blog Posting Month. The aim is to publish a new blog post every day in November. In the last few years, I've blogged pretty much constantly - daily for 2020, 2021, and 2023. A total of…

via Terence Eden’s Blog November 1, 2023

Jools Holland will be making London Underground station announcements tomorrow

Listen carefully on your commute on Thursday as you might hear Jools Holland on the tannoy.Read more › This article was published on ianVisits SUPPORT THIS WEBSITE This website has been running now for just over a decade, and while advertising revenue contri…

via ianVisits November 1, 2023

On "real name" policies

Some free software projects reject anonymous or pseudonymous contributions, requiring you to author patches using your “real name”. Such projects have a so-called “real name” policy; Linux is one well-known example.1 The root motivations behind such policies…

via Drew DeVault's blog October 31, 2023

Generated by openring


All posts on bearblog are licensed as CC-BY rss