Reading the page 107,Chapter 5. The X Window System on the official FreeBSD handbook and the problem is that's the official handbook does not explain something about installing and managing Wayland.
Arrived at this point a question rises in my mind - Is it even possible in 2022 install and use Wayland on any BSD distro to completely dump X11?
If yes how and where i can learn about this stuff ?
Thanks.
If you still need help and direction, I can give you some tips or guide, (or for anyone else), but I don't have an NVIDIA card so you will need to test that. I had heard NVIDIA added support a while ago and a quick search shows that it is working fine with driver 470 on Linux, which is in ports, so you may be in luck. If you get past that part, sway and wayland is easy to setup, works well and there are plenty of ports and packages that work with it.
Wayland might not be as popular yet for a handbook section, but the handbook chapter 5 that you mention (X Window System), still has the steps necessary to setup the graphics card for wayland too; just skip the parts that install and setup xorg and do everything else (you can uninstall xorg if you had already). There are a few settings after that, then install sway, a terminal emulator and you are basically done for a basic setup.
I'll go over the process, but here are some notes beforehand.
Wayland with window managers/compositors like Sway, Hikari, Wayfire etc work well but something like KDE on wayland probably still doesn't, idk. Avoid login/session managers like lightdm/sddm for now, sometimes they work, sometimes they break, try them later. Just run sway from tty. Also, just use packages (don't build ports) and it is probably better to set pkg to latest instead of quarterly right now. There were some newer versions of wayland, wlroots and sway added not long ago and I'm not sure what versions quarterly has at this point.
1) Setup. (don't know if you still need or did this part, it's considering a fresh freebsd install, skip ahead if needed).
- Update system if needed
#freebsd-update fetch install
reboot
- Change packages to latest
#mkdir -p /usr/local/etc/pkg/repos
Create a file called FreeBSD.conf containing
Code:
# /usr/local/etc/pkg/repos/
FreeBSD: {
url: "pkg+http://pkg.FreeBSD.org/${ABI}/latest"
}
Copy it to /usr/local/etc/pkg/repos/ (The comment in first line reminds you where it goes if you want to save it for later). Type
#pkg -vv
to check.
- Install packages like sudo and set it up. Editors like vim, neovim or whatever you need here.
- Install the graphics drivers as per chapter 5.4.3.
For my amd card I just
#pkg install drm-kmod
and add amdgpu to kld_list in /etc/rc.conf
#sysrc kld_list="amdgpu"
For nvidia, I think it's
#pkg install nvidia-driver
(not sure if you need nvidia-xconfig too for wayland). If that is the right one, you can try loading the module with
#kldload nvidia-modeset
before adding it to load on boot (in case it crashes). If it works fine, add it to kld_list
#sysrc kld_list="nvidia-modeset"
. Otherwise search for how to set up nvidia drivers (this part is the same as for xorg setups, just find the right way for nvidia and skip the xorg installs).
- Add your username to video group (and repeat for wheel group if you didn't already for sudo)
#pw groupmod video -m joebloggs
- Add procfs to /etc/fstab with this line
proc /proc procfs rw 0 0
- Install Sway, dbus and a terminal. Alacritty is always reliable.
#pkg install sway swayidle swaylock-effects alacritty dbus
You can run #pkg search sway and install anything else you need from the list (but not needed)
-Enable dbus and seatd
#sysrc dbus_enable=YES && sysrc seatd_enable=YES
-Add the environment variable XDG_RUNTIME_DIR to your shell. It can be /tmp, /var/run/user/{and your UID} or even a folder under home dir, as long as it's set.
That is it for sway to run. You can mount proc and run the services manually, then just type sway on your user account to run it, or just reboot to check if everything is working.. After reboot, check that /proc is mounted with
#df
.
Unlike x11, which uses tty9(F9), sway uses 1 or 2 ( i forget) but CTRL+ALT+F# keys work the same to switch to ttys.
2) Extra stuff.
- There are some extra environment variables you can set in your shell. Some are
MOZ_WAYLAND_ENABLE=1
If you use firefox (and thunderbird)
GDK_BACKEND=wayland
For gtk packages
QT_QPA_PLATFORM=wayland
For qt5 packages. Requires qt5-wayland manual install
TERMINAL=alacritty
Doesn't hurt to have, required by hikari if you decide to use it. change accordingly
Some others that I didn't find necessary, but...
XDG_DEFAULT_RULES=evdev
SDL_VIDEODRIVER=wayland
CLUTTER_BACKEND=wayland
QT_WAYLAND_DISABLE_WINDOWDECORATION=1 (never saw a difference really)
- Copy the default config to your folders
#cp -r /usr/local/etc/sway ~/.config/
. Edit to suit or check keybindings in ~/.config/sway/config
- I usually install mesa-gallium-va and mesa-gallium-vdpau for hardware acceleration, and mpv to check that my gpu is running fine (even in xorg). if you run mpv from command-line, it will show Dropping frames if there are hiccups, otherwise it's fine. Just
#mpv filename
and
#mpv -hwdec=auto filename
- Apart from that, you can look for wayland packages like I did. Google 'are we wayland yet" for a list, then #pkg search anything on the list to see if we have them on freebsd. Most are, not all. (the list is for linux).
- If you had xorg installed
#sudo pkg delete xorg
and
#sudo pkg autoremove