How to Configure Monitors with Sway on Linux
Vložit
- čas přidán 21. 08. 2024
- Sway is a tiling window manager like i3 but for wayland using the wlroots compositor. Since wayland is very different compared to XOrg/X11, you can't use the same commands like xrandr.
In this video, I show how to use swaymsg to configure displays (mode, resolution, position, refresh rate, etc) from the command line on Sway.
Note that for the average user, a graphical interface like wdisplays is probably much simpler. But also harder to script... There are also countless wrappers which try to act like xrandr but on wayland - use whatever works best for you!
I recently switched to regolith 3(from i3-Gnome with X11). Everything was working smoothly until one day(most likely I messed up something 😂) I was no longer able to adjust my monitors in the default Gnome settings app(Regolith does some Dbus magic to make it work with sway from what I understand). They were just no longer listed there. I saw that the functionality is powered by regolith-displayd and so I simply made that auto-start in my sway config. However every time I logged out or restarted sway/regolith my monitors would get sorted incorrectly.
I tried to figure out what I broke that I lost the ability to remember my monitors layout, but to no avail.
After watching your video, I made a simple bash script with the three swaymsg commands I need to arrange my monitors in my preferred layout, added that to my exec_always list in sway's configuration and now it works like a charm 💟 So thank you for the video! It was short, precise and to the point 🙂In fact I've probably spent longer writing this comment than watching the video 😂
Sway IS the compositor. wlroots is an extremely popular library implementing much of the wayland protocols (including many custom ones), not a compositor, that was originally part of Sway but was separated out for easier use by other projects (though I think it's still primarily targetting Sway).
Also wlr-randr (on sourcehut - not linking so YT doesn't swallow my comment) by the primary maintainer of Sway (Emersion) is a good choice for an xrandr clone.
Thanks for the clarification, I probably should have tried to be a little more clear describing sway and wlroots.
I'll also mention wdisplays as another tool that similar to arandr.