Sway
Sway is a tiling Wayland compositor. It's a drop-in replacement for the i3 window manager.
Prerequisites
First, install & configure eudev:
# apk add eudev # setup-udev
Then install graphics drivers appropriate to your system:
# apk add mesa-dri-gallium # gallium # apk add mesa-dri-classic # or classic # apk add mesa-dri-nouveau # for nvidia users
The following links contain guides for setting up the video stack.
Add yourself to the input and video groups:
# adduser $USER input # adduser $USER video
You have to log out and back in for this to take effect.
Install some TTF fonts:
# apk add ttf-dejavu
Since sway 1.6.1 (more specifically, since wlroots 0.14), you need to set up libseat backend if you wish to run sway directly (without nesting it in another wayland compositor). To do that, enable the community repository and choose one of the following methods:
- Option 1: seatd daemon (recommended)
-
# apk add seatd # rc-update add seatd # rc-service seatd start # adduser $USER seat
If you are already logged in as a $USER, you will need to relogin.
- Option 2: seatd-launch
-
# apk add seatd-launch
When starting sway, you will need to prefix invocation with
seatd-launch
. Note:seatd-launch
is a suid binary, so it might be wise to use one of the other methods from a security perspective. - Option 3: elogind daemon
-
# apk add elogind polkit-elogind # rc-update add elogind # rc-service elogind start
Using
elogind
will automatically set the necessary permissions, so you can skip adding groups likeseat
andvideo
Installation
We can now install sway:
# apk add sway sway-doc # apk add \ # Install optional dependencies: xwayland \ # recommended for compatibility reasons foot \ # default terminal emulator dmenu \ # default application launcher swaylock \ # lockscreen tool swaybg \ # wallpaper daemon swayidle # idle management (DPMS) daemon
Running Sway
To run sway, first set XDG_RUNTIME_DIR to a suitable location (e.g. create a .run folder in your home directory and set it to ~/.run). Then run sway from the Linux console (dbus-launch is used because pipewire needs it, it is included in dbus-x11 and you may omit it):
$ XDG_RUNTIME_DIR=~/.run dbus-launch sway
(if you run sway with seatd-launch, you will need to use $ XDG_RUNTIME_DIR=~/.run dbus-launch seatd-launch sway
)
You can also create a simple alias in your shell rc file (e.g. .zshrc), like:
alias swayinit="XDG_RUNTIME_DIR=~/.run dbus-launch seatd-launch sway"
See the Wayland page for a permanent configuration
swaylock needs to be able to read your /etc/shadow
file to be able to validate your password
Configuration and Usage
An example config is provided at /etc/sway/config
. Copy it to ~/.config/sway/config
and read through it to learn the default keybindings.
You might want to have gaps between windows, in which case add:
inner_gaps 20 outer_gaps 20
(replace 20 with the amount of pixels you want to be used for gaps) in your sway config.
You might have two monitors, and you might want to set their position, so here's an example of how to do it:
output eDP-1 mode 1920x1080@60Hz output eDP-1 position 1920,0 output DP-1 position 0,0 output DP-1 mode 1920x1080@120Hz
In this case, eDP-1 is the internal laptop monitor running at 60Hz and DP-1 is the external monitor running at 120Hz. The position of the laptop monitor is where the external monitor's width ends, so if the display is 1920 pixels wide and it is on the left, the laptop's monitor would be on the right, so it's width would start at the end of the second monitor's width, so at 1920. Replace the eDP-1 and DP-1 outputs with your own ones, and to change resolution and refresh rate, change the mode according to your parameters.
For additional information, start at man 5 sway
and read the upstream FAQ.