# Sway and Wayland



## PizdeX (Jan 11, 2022)

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.


----------



## angry_vincent (Jan 11, 2022)

Yes, i run it just fine for around a year or more. It was little bit involved to setup back then, but now it is very simple, assuming that you are using open source video card drivers, aka i915kms ( thats the one i use ). If you routing to install sway from default pkgs, then the only two things you need to add is seatd deamon i.e `sysrc enable seatd`. If you, otherwise, want to use ports, make sure BASU option enabled fro all ports it needs. Then, setting up XDG_RUNTIME_DIR would be the second


----------



## angry_vincent (Jan 11, 2022)

for second part of your question - completely dump X11, is more challenging. For example i use default pkgs from official  binary repository, but i do not have xorg-server installed at all. However there are number of small X11-related libraries, such a libX11 installed still , as many software still linking against them. Real example is firefox, it does need cairo and pango and gtk3 to be linked against some X11 libraries. So for as long upstream fix this, you have to deal with them. Reference bug for firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=1661450


----------



## drhowarddrfine (Jan 11, 2022)

PizdeX said:


> any BSD distro



Do not call them a "distro". It's a Linux term for how they do things. With the BSDs, they are complete operating systems unto themselves. You are either running FreeBSD or you are not. There are no "distros".


----------



## PizdeX (Jan 11, 2022)

So what's about Nvidia drivers ???
i'm actually using an laptop where the main gpu is an Nvidia GTX 1050 Mobile,can i do something on FreeBSD or it's already an dead start?


----------



## kpedersen (Jan 11, 2022)

drhowarddrfine said:


> There are no "distros".



We run the original Berkely Software Distribution Distribution (BSDD)

But which BSDD Distro do you run? 



PizdeX said:


> Is it even possible in 2022 install and use Wayland on any BSD distro to completely dump X11?



Even in 3022 there will probably still be fragments of X11 libraries pulled in as dependencies (assuming Wayland is still around by then).

But if you can live with that, I believe sway is working quite well. One possible advantage of having so few options when it comes to compositors is that it should be easier to find specific instructions to get it running.


----------



## PizdeX (Jan 11, 2022)

kpedersen said:


> We run the original Berkely Software Distribution Distribution (BSDD)
> 
> But which BSDD Distro do you run?


I'm trying to run FreeBSD 13.


----------



## drhowarddrfine (Jan 11, 2022)

kpedersen There is a difference between distributing a software package and packaging software. FreeBSD is Berkley's distribution of their software to their constituents. A Linux distro (their created term for themselves and no one else) is a description of how they packaged up their kernel with other software as an OS. Not the same thing and not the same context.


----------



## kpedersen (Jan 11, 2022)

drhowarddrfine said:


> Not the same thing and not the same context.


Absolutely agree. I just wanted to see how many superfluous "Distributions" I could get in the name


----------



## Alain De Vos (Jan 11, 2022)

angry_vincent said:


> Yes, i run it just fine for around a year or more. It was little bit involved to setup back then, but now it is very simple, assuming that you are using open source video card drivers, aka i915kms ( thats the one i use ). If you routing to install sway from default pkgs, then the only two things you need to add is seatd deamon i.e `sysrc enable seatd`. If you, otherwise, want to use ports, make sure BASU option enabled fro all ports it needs. Then, setting up XDG_RUNTIME_DIR would be the second


Note, cmus,seatd,sway,swayidle have option BASU on by default.


----------



## PizdeX (Jan 12, 2022)

Alain De Vos said:


> Note, cmus,seatd,sway,swayidle have option BASU on by default.


I don't understand,what's are those?
Loonix dependencies which use's to keep their software only for loonix?
So this mean's that in order to put Sway on FreeBSD i need to turn on "Linux Binary Compatibility" mode ?

P.S. I'm totally newbie.


----------



## angry_vincent (Jan 12, 2022)

you don't need to worry about this option. i don't know what is loonix, maybe a fun word for linux?
you don't need to turn on Linux Binary Compatibility to setup sway.


----------



## PizdeX (Jan 12, 2022)

Got 1 last question.
By installing Wayland + Sway or Kde do i need to install some systemD trash or i can avoid it completely?
Thanks.


----------



## angry_vincent (Jan 12, 2022)

No, no such thing exist


----------



## Minbari (Jan 12, 2022)

Since you are forced to use x11-servers/xwayland to run apps I don't see the point to run Wayland. I'll stick with the old, but reliable good x11/xorg.
PS: RedHat FU!


----------



## Minbari (Jan 12, 2022)

kpedersen said:


> We run the original Berkely Software Distribution Distribution (BSDD)


Actually we don't run the original code. FreeBSD use the code from "Jolix" (386BSD) which was written  Lynne Jolitz and William Jolitz. That's why FreeBSD or NetBSD had no problems when UNIX System Laboratories, Inc. made a lawsuit against  Berkeley Software Design, Inc. (BSDi) [BSD/OS a.k.a BSD/386]
and The Regents of the University of California.
Berkeley Software Design Inc. (BSDi) is the actual iXsystems, Inc. which developed PC-BSD (TrueOS) and now "develops" TrueNAS.


----------



## angry_vincent (Jan 12, 2022)

this is no such a strict requirement or forcing of xwayland, however, it varies on a software you use. there is no such software on my box. i also set xwayland disable in my sway config.


----------



## kpedersen (Jan 12, 2022)

angry_vincent said:


> this is no such a strict requirement or forcing of xwayland, however, it varies on a software you use. there is no such software on my box. i also set xwayland disable in my sway config.


Just because you disable xwayland in the config, it doesn't mean much of Xorg isn't still linked in the program and all over the hard disk as a fairly sizable dependency.


----------



## grahamperrin@ (Jan 15, 2022)

PizdeX this is a few days late: _welcome to FreeBSD Forums_.

If you like, join the discussion under <https://forums.freebsd.org/posts/551445>; there's some insight into how the FreeBSD Foundation is improving things for laptop users.



PizdeX said:


> … laptop where the main gpu is an Nvidia GTX 1050 Mobile …



Elsewhere in the forums there are a few mentions of GTX 1050, but maybe not _Mobile_. If you'd like to start a new topic with *NVIDIA GeForce GTX 1050 Mobile* in the title, it'll be easier for people to provide focused help. Thanks.


----------



## grahamperrin@ (Jan 15, 2022)

drhowarddrfine said:


> The problem you are having is you took my opinion of reddit and made it into a personal attack on you.



No, that's not the problem that I'm having.


----------



## Crivens (Jan 16, 2022)

grahamperrin said:


> No, that's not the problem that I'm having.


So which problem do you have?


----------



## grahamperrin@ (Jan 16, 2022)

I should prefer to discuss Sway and Wayland.


Historically, the problems are largely elsewhere in the forum. Drawing attention to things that were _far from nice_, with or without external archives, might cause excitement in the short term, but ultimately: it will not look good. Ugliness breeds ugliness.

Please, let's all move on, with mutual respect, with respect for _all_ FreeBSD communities. Be nice. Be nice, everyone.


Here, let's discuss Sway and Wayland.


----------



## macbias (Jan 19, 2022)

PizdeX said:


> 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

```
# /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`


----------



## grahamperrin@ (Jan 20, 2022)

Thanks,



macbias said:


> … you can try loading the module with `#kldload nvidia-modeset` …



Better to begin with the primarily recommended module, than with the module that's intended for problem cases.


----------



## DutchDaemon (Jan 20, 2022)

To whom it may concern: If you don't want to end up in constant and painfully slow moderation queues, I suggest the (mutual; removed) sniping ends here. Looking the other way is a legal turn here.


----------



## shkhln (Jan 20, 2022)

grahamperrin said:


> Better to begin with the primarily recommended module, than with the module that's intended for problem cases.


You were already told which way is the correct way. Multiple times. By different people. Either buy an Nvidia card and verify it yourself or don't bother.


----------



## grahamperrin@ (Jan 20, 2022)

PizdeX said:


> i'm actually using an laptop where the main gpu is an Nvidia GTX 1050 Mobile



PizdeX if it helps, various hardware probes show use of `nvidia` (the primarily recommended module) for _GP107M [GeForce GTX 1050 Ti Mobile]_.

In chronological order:

<https://bsd-hardware.info/?probe=e7db61fd34#pci:10de-1c8c-17aa-2267>
<https://bsd-hardware.info/?probe=3d7c8e695c#pci:10de-1c8c-17aa-2266>
<https://bsd-hardware.info/?probe=e0f096eb0d#pci:10de-1c8c-17aa-2266>
<https://bsd-hardware.info/?probe=6d5e1a13d0#pci:10de-1c8c-17aa-2267>
<https://bsd-hardware.info/?probe=4fbb430947#pci:10de-1c8c-1d05-1044>
<https://bsd-hardware.info/?probe=0a1683170a#pci:10de-1c8c-1d05-1044>
If GeForce GTX 1050 _Ti_ Mobile (probed) is significantly different from GTX 1050 Mobile (yours): sorry, this was not previously explained to me. A few months have passed since I used FreeBSD on a notebook with NVIDIA graphics.

The maintainer of x11/nvidia-driver very recently wrote:



> It's all thoroughly documented in the x11/nvidia-driver/files/pkg-message.in, …



A highlighted view of *the package message*, as it appears in FreshPorts:


----------



## shkhln (Jan 21, 2022)

I'd suggest taking that issue to the maintainer instead of posting misinformation everywhere. (And, no, your massive link dumps are never helpful. They might be well intended, but that doesn't make them any less confusing.)


----------



## grahamperrin@ (Feb 3, 2022)

macbias said:


> … something like KDE on wayland 𡀦… - Add `procfs` to /etc/fstab …



Incidentally, from the KDE Community Wiki:



> > We're advised that KDE software should – already – use libprocstat or another FreeBSD API; that proc is no longer a requirement.



Maybe required for other things, but technically not for KDE Plasma. If you become aware of any exception, please let us know. Thanks.

procfs(5)

libprocstat(3)


----------



## grahamperrin@ (Mar 14, 2022)

grahamperrin said:


> … The maintainer of x11/nvidia-driver …



Related, following clarification: 



grahamperrin said:


> Thanks. Open a bug report for improvement of the package message:
> 
> …


----------



## r2com (May 14, 2022)

alright so now I wanna try this swaywm and stumbled upon this forum, after trying as far as I can, so far I got error after running "sway" "Found 0 GPUs"
any ideas now? I have Intel® HD Graphics 4600 in that machine

and bigger question is..is it actually worth it? I saw someone on this thread saying that x11 is used in one or another way even with this setup... anyway, so is this experiment technically will do any better for me?
because if not id rather not continue and use awesomewm


----------



## Alain De Vos (May 14, 2022)

Sway is not mature, it has some bugs.
But i used sway in the past and it is almost like i3
Here is my start script,

```
#!/usr/local/bin/zsh
export XDG_SESSION_TYPE=wayland
export GDK_BACKEND=wayland
export QT_QPA_PLATFORM=wayland
export SDL_VIDEODRIVER=wayland
export CLUTTER_BACKEND=wayland
export BEMENU_BACKEND=wayland
export WM=sway
export QT_QPA_PLATFORMTHEME="qt5ct"
export XKB_DEFAULT_LAYOUT="be(nodeadkeys)"
export XKB_DEFAULT_RULES=evdev
export XDG_RUNTIME_DIR=/home/x/TMP
exec seatd-launch sway
```

labwc works also good.


----------



## ziomario (Dec 31, 2022)

kpedersen said:


> We run the original Berkely Software Distribution Distribution (BSDD)
> 
> But which BSDD Distro do you run?
> 
> ...


----------



## Alain De Vos (Dec 31, 2022)

I prefer "labwc"


----------



## Voltaire (Jan 2, 2023)

> But if you can live with that, I believe sway is working quite well. One possible advantage of having so few options when it comes to compositors is that it should be easier to find specific instructions to get it running.





> and bigger question is..is it actually worth it? I saw someone on this thread saying that x11 is used in one or another way even with this setup... anyway, so is this experiment technically will do any better for me?
> because if not id rather not continue and use awesomewm


One of the reasons Wayland would be so good is for performance, because it would be more efficient than Xorg. But in benchmarks I don't think Wayland is ever faster than dwm + Compton on average. Another reason you should use it is that it would be pixel perfect. But dwm + Compton can also completely prevent tearing and I don't think you will see the difference in practice with a dwm + Compton that is configured correctly. One last big advantage of Wayland would be security. I don't have enough knowledge to make a statement there, but Xorg has been the standard for many years, and new projects usually have more bugs. So I'm not 100% sure that the security will be better now. Perhaps it will be the case in the future.


----------

