Wayland and some window managers

Now that RedHat's announced they aren't including X11 in RHEL10, one wonders if all others will follow, as they did with systemd. This is not a detailed Wayland tutorial, it just goes over a few problems I ran into using labwc, similar to openbox on Fedora 39 and FreeBSD-14, and dwl, a replacement for dwm on FreeBSD.

If you use Fedora's default Workstation install you may not even notice any differences, it defaults to Wayland, and things work without issue. To tell if you're running Wayland or X, try running
echo $XDG_SESSION_TYPE

If it comes back Wayland, you're using Wayland.

I prefer a minimal install of Fedora, then add X, usually running openbox. To try labwc, I ran
dnf install labwc

and it seemed to pull in all dependencies. If you've done the workstation install, with Gnome, all this is taken care of, but with my minimal install, once installing labwc, it would't start. Firstly, you need to set the XDG_RUNTIME_DIR (and this holds, I think, for any Wayland window manager.) So
XDG_RUNTIME_DIR=/tmp labwc 

would work to get it started. However, I didn't want to do that each time, so I set XDG_RUNTIME_DIR in my $HOME/.bashrc.

Now, however, I suddenly had no sound. Checking error messages when I tried to play a video with mpv showed me that mpv was having a problem with me using /tmp or /var/tmp, as my XDG_RUNTIME_DIR, as both directories, though my user could write to them, were owned by root. So, playing around a bit, I saw that by default, mpv used /run/user/ so, I changed my .bashrc entry to
export XDG_RUNTIME_DIR=/run/user/$(id -u)

I prefer id -u to $UID, as I also work a lot with FreeBSD, and id -u will work in sh, whereas $UID won't.

The labwc window manager has a good getting started page which goes through a few basics such as how to set an image background and so on. It will have its config files in $HOME/.config/labwc. With openbox, I use autostart.sh, labwc calls its startup script autostart. You can just copy over your openbox rc.xml file and most of it will work. A couple of things didn't work for me, but when I investigated (see the link for actions in the next paragraph), it would usually turn out to be a syntax difference, such as ToggleMaximize, which though it worked in openbox, needed to be ToggleMaximizeFull in labwc.

There was also the MoveToEdge action. In openbox, one uses north, south, east, and west. In labwc, one uses up, down, left, and right. There's a description of actions for labwc at manker.com.

The FreeBSD handbook has a section on using Wayland. Basically, one installs wayland and seatd. Add yourself to the video group. Then, I found that when I installed labwc and/or dwl, they pulled in some more necessary packages.

FreeBSD now has an nvidia-drm-kmod package. I wound up installing more than one, but I think the one I wanted (as of February,2024) was the nvidia-drm-kmod-535-146.02 package as that's the one that matches the driver I have. At any rate, to get it working, I added this line to my /etc/rc.conf.
kld_list="nvidia-drm"

When I added that line, I was able to, once I started the seatd service, use labwc. (I didn't try dwl).

Again, you also have to set the XDG_RUNTIME_DIR. The handbook's suggestion is to set it to /var/run/user/$(id -u). Some users feel this might cause issues and feel it's better off in something like $HOME/.cache/run
mkdir -p $HOME/.cache/run
chmod 0700 $HOME/.cache/run

Again, I put it in my $HOME/.bashrc.
export XDG_RUNTIME_DIR=$HOME/.cache/run

You can add seatd to /etc/rc.conf so that it's always running.
sysrc seatd_enable="YES"

In my case, as I was just playing with it I would just start seatd when I was going to use a Wayland window manager.
sudo service seatd onestart

Then, after a few days, it stopped working for me on FreeBSD with NVidia. I don't know why. I would start seatd, load the module, then type dwl to start the dwl window manager, and I'd get a message that there was no client on seat0. So, for now, I've stopped trying it on my workstation with an NVidia card, but it's working, at least for some people on FreeBSD forums.

On FreeBSD (and presumably on Linux, but I didn't check), dwl is similar to dwm. I ran make extract in the /usr/ports/x11-wm/dwl directory. I then copied the work/dwl directory to $HOME, copied config.defaults.h to config.h and edited that to make a few custom changes. It is slightly different than dwm's config.h file. For example to use the shift key as part of a keyboard short cut, dwm uses MODKEY|ShiftMask. The dwl window manager uses MODKEY|WLR_MODIFIER_SHIFT. This also changes what you put in for the XKB_KEY.

For example, dwl's default equivalent to dmenu is bemenu. (Though dmenu probably works.) The keyboard shortcut is MODKEY_p, like dmenu's. I like to use MODKEY_p for something else, so I changed bemenu's shortcut to MODKEY+shift+p.

However, that didn't seem to work. Looking at the config.def.h file, one sees this message as a comment.
/* Note that Shift changes certain key codes: c -> C, 2 -> at, etc. */:

Of course, I missed that. Anyway, I had to change my menucmd line to
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_P,     spawn,          {.v = menucmd} },

In other words, I had to use P, not p. The default modifieer is Mod1 or the alt key, however there are instructions right there to change it to MOD4, the Windows key.
/* If you want to use the windows key for MODKEY, use WLR_MODIFIER_LOGO */
#define MODKEY WLR_MODIFIER_ALT

This is a change I make as I prefer using the Mod4, so my define MODKEY line reads
#define MODKEY WLR_MODIFIER_LOGO

One uses a custom configuration like one does for dwm. I use portmaster so it's
cd /usr/ports/x11-wm/dwl
portmaster -m 'DWL_CONF=/home/scottro/dwl/config.h' x11-wm/dwl'

The dwl window manager's home page is on github with much useful information.

As I said, I haven't done much with Wayland, just tested these two drop ins for my two main window managers on Fedora (where I only tested labwc) and FreeBSD. My hope is that this page might save someone a bit of frustraion, such as choosing a bad location for XDG_RUNTIME_DIR, and suddenly finding they have no sound, or someone, who like me, missed the notice in dwl's config file and couldn't understand why a shortcut made with WLR_MODIFIER_SHIFT wasn't working.

If one looks at some discussions on the net about Wayland, one is reminded of the hate for systemd. Some people hate it, some think it's great. As for me, I'll stick with X if I can, but the change wouldn't affect me that much.

If one looks at some of the arguments on the Internet, one sees that there are various use cases where Wayland isn't working as well as X did for many. In my various use cases, I found that using labwc or dwl is much like using openbox or dwm, and causes me few problems.

I don't know if this page does anything but show my ignorance, but it is hoped that at some point it helps someone.