Trying out Sway

The Jupiter Broadcasting crew have been all about Wayland recently, so I thought I would have a look and see how far things have come for my beloved i3wm.

A very long way. Sway (the wayland-capable i3wm successor) looks superb. I'm testing it out on my Galago Pro (the older 2nd gen one) with a HiDPI screen and it looks beautiful. That HiDPI screen has been a bit of a mixed bag; everything looks reasonably sized and proportioned under X now, but it took a lot of tweaking, prodding, coaxing and testing before I got it just so.

But wow, it looks good with Wayland. Crisp. These screenshots cannot possibly do it justice.

The default sway desktop

It's going to be a wrench going back to X.org ...

Konsole in wayland glory

but I'm going back.

The setup

Installing sway was a piece of cake; it's in the community Arch repository these days. Once it was installed, I logged out, and Sway was an option in the login screen (GDM in my case).

Easy.

First login, and I am greeted with some errors.

Initial sway errors

Sway is trying to parse my i3wm config and clearly isn't happy about something. That's OK, I didn't want to use it anyway, so I copied the sample sway config from /etc/sway/config to ~/.config/sway/config.

Sway has some pretty nice defaults, including vim movement keys. (i3wm's defaults of jkl; make sense and I still don't like them. The preferred terminal is hard-coded into the file (stock default is urxvt - more on that in a moment) rather than i3-sensible-terminal which feels like a step backwards.

Preserving the Environment

Or it would be, if my environment variables had survived the switch. The first clue that something was wrong was when I opened my first terminal window.

urxvt (unstyled)

Yuck. Of course! X.resources.d won't work here. Neither will environment variables, so $TERMINAL isn't set, or my $PATH as it turns out.

No matter though; it's a good excuse to clear out the environmental clutter that has accrued over the years; a fresh start with systemd environment variables. Creating ~/.config/environment.d/envvars.conf and populating it with key/value pairs will do it. You can check it works with systemctl --user show-environment.

My $PATH still isn't available to rofi though, or indeed it's wayland-ready counterpart, wofi

It was pretty obvious that plenty of applications were running in XWayland [1], they all had a strange fuzzy look. It was pretty obvious when something was using XWayland, but I found a fun way of checking anyway. Everything QT was still X-ed up, but that was because I was missing the qt5-wayland package.

Making stuff 1 bigger

Display scaling on Wayland is a breath of fresh air after X.org. Set it in sway's configuration file (~/.config/sway/config, remember?) and watch it apply to everything.

output eDP-1 scale 2

I've got scaling nearly right under X, but it's still not perfect. Sway or Wayland or whatever is doing this magic is so much better. Apart from konsole - konsole is waaay too big. Setting the font to something smaller sorted that, but is size 13 font being scaled to size 26 font or something? It's fisher-price-big.

Sway has a command for checking the output names as well, since I guess xrandr won't be all that useful any more:

swaymsg -t get_outputs

You can use the output names for setting backgrounds using sway's built-in wallpaper tool as well, but I left this as stock for now.

Passwords and clipboards and struggles

So far the stumbling blocks were all solvable, but the big road-block hit as soon as I tried to use my password manager.

I use pass (the standard unix password manager) and oxen and wain-ropes will not make me change it. It supports wl-clipboard, but I haven't figured out how to get wl-clipboard to actually paste things into windows yet.

Rofi-pass, my favourite frontend for pass, is working feverishly on Wayland support. I tested it out by removing the rofi-pass package and installing

  • libevdevplus-git
  • libuinputplus-git
  • ydotool-git
  • rofi-pass-ydotool-git

..., all from the AUR. It kinda worked if you launched ydotool with sudo from another terminal window, but seemed to skip the first 4 characters from the autotyping. It'll get there; carnager seems really cool and has put a lot of work into rofi-pass. Oh wow, they've written a similar frontend for todo.sh as well? I've gotta play with that.

What else?

I played about with bemenu as a drop-in replacement for dmenu, and that seemed pretty straight-forward. It uses GNU-friendly double -- for long options as well, which is really nice. That meant that my pilfered shutdown menu looked all crisp and clean:

#!/bin/bash
while [ "$select" != "Cancel" ] && [ "$select" != "Logout" ] && [ "$select" != "Shutdown" ] && [ "$select" != "Reboot" ]; do
    select=$(\
       echo -e 'Shutdown\nReboot\nLogout\nCancel' | \
       bemenu \
         --nb '#2f343f' \
         --nf '#f3f4f5' \
         --sb '#9575cd' \
         --sf '#f3f4f5' \
         --fn '-*-*-medium-r-normal-*-*-*-*-*-*-100-*-*' \
         -i \
         -p "Are you sure you want to logout?"\
    )
    [ -z "$select" ] && exit 0
done
[ "$select" = "Cancel" ] && exit 0
[ "$select" = "Shutdown" ] && systemctl poweroff && exit 0
[ "$select" = "Reboot" ] && systemctl reboot && exit 0
swaymsg exit

grim instead of scrot, imv instead of feh... there are very few compromises that I'd need to make in order to switch to Wayland full time.

Once rofi-pass is a bit more usable and ydotool is more polished, I'll be ready to go full-time Wayland.

Except for all the bloody Nvidia cards I have. Fuckssake Nvidia.

Addendum

Having switched back to X, I've noticed that things look pretty crisp over here as well; so much so that I'm beginning to doubt whether I noticed a difference or not. Perhaps cleaning the screen at the same time as switching compositor introduces one-too-many variables for a truly scientific comparison?

[1]Runs X apps in Wayland