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 and dwl, a replacement for dwm, on Fedora 40 and FreeBSD-14.x

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. At the time, I had to play with setting my XDG_RUNTIME_DIR, but it seems that now (running F40 at time of writing) it should work without further configuation.

I also use it in VoidLinux, though there's a little more preparation. You have to, in Void, have the seatd daemon running (also true in FreeBSD). This is done with, as root or with sudo
ln -s /etc/sv/seatd /etc/runinit/runsvdir/default

Also with Void, one still has to set the XDG_RUNTIME_DIR. (FreeBSD and Fedora do it automatically). I've seen various suggestions, but I find that what works for me is
export XDG_RUNTIME_DIR=/home/scottro/.cache/run

You will have to create the ~/.cache/run directories.

I expect that sooner or later, it will become automatic in Void, as well.

NapoleonWils0n also has some useful pages on getting Wayland to work with NVidia. Links are in a thread on the forums which can be found here He also has a detailed video on youtube,useful for anyone interested in either Wayland with NVidia on FreeBSD or the dwl window manager.

One thing that has probably become necessary is adding
hw.nvidiadram.modeset=1

to /boot/loader.conf. However, when I added this, in an effort get it working, suddenly, if in X, when using ctl+alt+funcX to get a virtual terminal, or even if I killed X to get to console, I only had a black screen, often with some color splash artifact. I could, when in one of these artifact filled screens, get back to X by blindly typing startx in console, or if at a VT hitting ctl+alt+F9. I found the fix for this on the forums, One way, is to go to using the legacy syscons console, by adding kern.vty="sc" in /boot/loader.conf, but I chose adding hw.vga.textmode=1 in /boot/loader.conf. Either way will work.

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. The easiest is to use the included rc.xml.all which is usually included with labwc in docs or examples and edit that.

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. 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 or dwl.

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

In my case, as I only use it on occasion, I just start seatd when I use a Wayland window manager.
sudo service seatd onestart

On FreeBSD and Linux, 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 wmenu. (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 wmenu'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 in the config file 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 on FreeBSD, 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 was on github, but has moved to codeberg.org. As I said, I haven't done much with Wayland, just tested these two drop ins for my two main window managers on Fedora and FreeBSD. My hope is that this page might save someone a bit of frustration, for 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.

I sometimes hook my laptop to our TV, to watch movies, do exercise videos, etc. I've found pipewire useful for getting sound through the TV's speakers. Wayand seems to run videos more smoothly than X11. With Wayland, the two window manmagers I've used, labwc and dwl, both use the laptop's screen as the primary screen, meaning that to get a movie, terminal, or whatever onto the TV screen takes a bit of effort.

With labwc, I can move things with keyboard shortcuts, with dwl, I have I've found I have to hit the mode button, then button one on the mouse to move a window, though I don't have to put it in floating mode. Neither is terribly difficult, but I did find a wayland version of xrandr, that makes it a bit simpler. I use wlr-randr, which in many ways works like xrandr. For my purposes, I just want it to turn off the laptop's display, so everthing is on the TV. If i just run wlr-randr without any options, it shows me both displays and possible sizes. It shows the laptop's display as eDP-1, in FreeBSD and Fedora. versions I use, Fedora and Void. So, when I hook the laptop to the TV, I run
wlr-randr --output eDP-1 --off

This turns off the laptop monitor and uses the TV to view whatever video I may want to watch. In X I can use xrandr, take the name it gives the TV, and just set that monitor to --primary. I only need to do that with openbox, though, both fluxbox and dwm set the TV as the primary monitor when it's connected.)

The other simpler option, with dwl is to just keep moving your mouse to the right until it appears on the TV screen. I've found that if I do that, then any terminals opened, or commands run from wmenu, or wmenu itself, will, if the mouse shows on the TV, rather than the laptop's screen, open on the TV. This actually works with labwc as well, but for me, it's just easy to use my keyboard shortcuts to move the window over to the right which puts it on the TV.

With dwm, in X, I like to have my status bar show the date and time. With dwl, I use dwlb, a similar status bar to dwm's builtin bar. To get it the size I like, I use, taken from a few people, mostly Naopolean Wils0n, on FreeBSD forums. and start dwl with
exec dbus-launch --exit-with-session dwl -s 'dwlb -font "monospace:size=12"'  2>/dev/null

This opens dwl with a status bar. To get the date in the bar, I then, use wmenu to run
(while true; do date +"%R %F";sleep 60;done &)|dwlb -status-stdin all

This gets the status bar working the same way that dwm's builtin bar works. (That one is thanks to user jb82 on FreeBSD forums).

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. However, while this is completely anecdotal, and may only apply to my particular laptop and TV, I do find that if I play a video from my laptop on the TV, the video seems smoother, in both Fedora and FreeBSD, if I use Wayland.

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