localhost

sorting the wheat from the chaff

Wayland: worth a try?

After watching a talk about the Hikari window manager, I was slightly horrified by how Wayland have been released since 10 years and still X11 is everywhere. So I decided to try it and see why.

The summary is: if you use Gnome (maybe also KDE through KWin?), Wayland may be usable for the average user. On the other hand, if you use a more niche window manager, it will be more fun :-)

An important limitation about Wayland: screen sharing applications (conferencing and WebRTC apps webapps) seems to not work well at this time (and this is a dealbreaker for many).

This said, a lot of X11 applications will work under Wayland because of some magic provided by Xwayland, an X11 client that forwards all Wayland events to X11 seamlessy; in the end this means that you can stay on a mixed X11/Wayland desktop and migrate at your own pace (or - more likely - at the pace of development of applications you need to support Wayland).

So, on a recent Ubuntu 19.x, I simply had to logout and login again using Gnome/Wayland. Done. Enjoy Wayland and find what's not working.

If you use another window manager, read on, here be dragons.

§ Installing Sway

Under X I use i3 window manager, so the obvious choice was to install the Sway window manager which provides almost full compatibility with i3 config files (in my case just small adjustements). I've immediately noticed an annoying name clash with a Microsoft product, so search results are always a bit dirty. I am confident that the window manager will outlive the Microsoft product, so I'll just wait :-)

Important gotcha about Sway: it won't work with the nVIDIA proprietary drivers but will work with Nouveau, see the Hacker news discussion and the Wiki.

Sway is a project run by a fistful of heroes, they wrote their own Wayland compositor (wlroots) and other "utilities" like a wallpaper manager and all kind of ancillary stuff that you don't even see, but it's there and need constant maintenaince.

Sway has some rough edges but the project is incredibily active (I'll get to this in a bit) and the maintainers are quick to give feedback. These guys definitively need to be supported (I did).

So, the basic Sway configuration works fine, the fun starts when you need to customize and add features.

Some sparse tips:

  • To see if an application is running under XWayland, use xeyes and hover over the application. If the eyes follow your cursor, that's a X11 application running through Xwayland.

  • Add these env variables for toolkits and applications to make them run on Wayland:

    • GTK: GDK_BACKEND=wayland (but not on Firefox)
    • Qt: QT_QPA_PLATFORM=wayland-egl
    • Clutter: CLUTTER_BACKEND=wayland
    • SDL: SDL_VIDEODRIVER=wayland

    Setting these variables seems to make Firefox and Thunderbird less stable and prone to crashes (TODO: investigate).

  • Check if we are running Wayland

    $ echo $XDG_SESSION_TYPE
    wayland
    

§ Getting to the edge

Sway is a project run by a small number of volunteers, the main focus is the Arch Linux distribution (btw); this means that all the tools and components are packaged for other distributions (Debian, Ubuntu, etc.) by other volunteers. Given the pace of development of these tools, it's easy to run into issues because you have installed an "old" version of something ("old" being a couple of months before).

This is why I've decided to prepare a workflow to compile myself everything from the latest git stable tags. It's a work in progress and since I don't want to pollute my workstation with a lot of development packages, I'm experimenting with a Docker container and the OpenSUSE packaging service (there are already Sway build there that I can probably use as guidance). I will update this article when I'll have figured something.

If you are reading this and have suggestions, please let me know ;-)

UPDATE: I kind of found my way through a Docker container solution. Read here for more info. Using the build service from openSUSE is still not understood.

§ Replacements

Besides rewriting parts of my i3 scripts to adjust them for Wayland, I'd like to replace my current X11 applications and utilities with "native" ones to see how far I can go. Here's a list I will keep updated:

  • xclip: wl-clipboard
  • dmenu: dmenu-wayland
  • mpv: works fine
  • Firefox/Thunderbird: the porting to Wayland is in progress, there are some rough edges. Can be used under Xwayland. Or pure Wayland setting MOZ_DBUS_REMOTE=1 and MOZ_ENABLE_WAYLAND=1. There is a firefox-wayland package but reports do not indicate to work very well. Tracking issue.
  • dmenu: dmenu-wl
  • py3status (a better status bar for i3): swaybar
  • Gnome application Wayland support
    • blueman-amanager: supports Wayland
    • nm-applet: supports Wayland (but broken: workaround is to force X11 backend, e.g. GDK_BACKEND=X11 nm-applet --indicator)
      UPDATE: fixed in v1.8.24
    • gnome-terminal: supports Wayland
    • gnome-screenshot: broken
  • password-store uses xclip to copy passwords in the clipboard. Wayland support has been merged but not yet released (as of January 2020). Need to check out the master branch. Install with PREFIX=~/.local make install.

§ Open issues

  • Cannot copy and paste anymore to and from Emacs: the issue is with the xclip.el package, it does not use correctly wl-clipboard. Opened a bug report. SOLVED by updating to wl-clipboard 2.0

  • wl-clipboard shows weird visual artifacts, (also reflects when using in Emacs with xclip.el, appends ^M whitespaces). SOLVED by updating to wl-clipboard 2.0

  • Firefox: sporadic UI blocks

    • See dunst problem
  • screen lock (on lid close) sometimes doesn't work (screen is not locked before sleep mode)

  • Sometimes the WiFi network is disconnected

  • Sway sporadic crashes (esp. when reloading the configuration) and I am taken to the login.

    TODO: investigate these errors (if related):

    Jan 16 08:33:02 localhost xdg-desktop-por[2998]: Failed to get application states: GDBus.Error:org.freedesktop.portal.Error.Failed: Could not get window list: Cannot invoke method; proxy is for the well-known name org.gnome.Shell without an owner, and proxy was constructed with the G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START flag
    
    Jan 31 13:21:25 localhost xdg-desktop-por[2225]: Failed to get application states: GDBus.Error:org.freedesktop.portal.Error.Failed: Could not get window list: Cannot invoke method; proxy is for the well-known name org.gnome.Shell without an owner, and proxy was constructed with the G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START flag
    
  • nm-applet crashes when getting connection information, issue.
    UPDATE: fixed in v1.8.24

  • gnome-terminal cannot open web links (from the "Open Link" shortcut), sometimes crashes when I try too hard :-)

    Jan 24 13:17:47 localhost gnome-terminal-server[27398]: Error: no DISPLAY environment variable specified
    
  • DBus notifications daemon (dunst) block Thunderbird for some seconds until all mailbox have been checked. Possibly other applications, too.

    Feb 20 10:37:21 valkyrie systemd[1672]: Starting Dunst notification daemon...
    Feb 20 10:37:21 valkyrie dunst[5577]: CRITICAL: Cannot open X11 display.
    Feb 20 10:37:21 valkyrie systemd[1672]: dunst.service: Main process exited, code=exited, status=1/FAILURE
    Feb 20 10:37:21 valkyrie systemd[1672]: dunst.service: Failed with result 'exit-code'.
    

    Solution: replace dunst with mako, see this issue.

    Tried to manually run dunst -verbosity debug and notifications seem to work.

  • Polkit manager does not start or is broken. This is reflected in subtle errors on running stuff that require root permissions and just breaks, example Installing Virtualbox extension pack:

    VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.1.8-75467.vbox-extpack
    

    Workaround: install with sudo. Need to find a way to start Polkit. Traces here, here and here.

§ Resources

https://forum.manjaro.org/t/tale-of-the-young-boy-who-migrates-from-i3-to-sway/59618

https://github.com/swaywm/sway/wiki#configuration

https://gist.github.com/toger5/3a509d9a9d7ebba1e02205b00449ccff

https://old.reddit.com/r/swaywm/comments/eg0efb/what_components_do_i_need_to_assemble_a_complete/