I’m starting a new blog series about Sway, a Wayland Tiling Window Manager (the Wayland version of i3). Though I’ve already blogged about Sway, this post (and a few future ones) are intended as “getting started tutorials”.
I’ll focus on Sway in Arch, in particular, EndeavourOS.
Let’s start by installing EndeavourOS with no graphical environment installed:
Once the installation is finished, let’s log in to a terminal session since we have no Desktop Environment.
Let’s install the main package:
1 |
sudo pacman -S sway |
The output shows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
Sway requires additional setup for privilege escalation. Without this setup, sway will fail to start with session activation permission failures. Choose one of the two available options (In alphabetical, not recommended, order): 1. polkit: This will make sway "just work" right after installation but may be a weightier solution than desired. 2. seatd: Already required as a sway dependency, this is a lighter-weight solution but requires some user configuration: Enabling the service, adding your user to the "seat" group, then logging out/in again. Either option should provide the same functionality/stability. Refer to the Sway wiki page for information. Optional dependencies for sway dmenu: dmenu_path support (used alongside wmenu in default $menu) foot: Terminal emulator used in the default configuration i3status: Status line generation mako: Lightweight notification daemon polkit: System privilege control. Required if not using seatd service [installed] swaybg: Wallpaper tool for sway sway-contrib: Collection of user-contributed scripts for sway swayidle: Idle management daemon swaylock: Screen locker waybar: Highly customizable bar wmenu: Application launcher used in default config xorg-xwayland: X11 support xdg-desktop-portal-gtk: Default xdg-desktop-portal for file picking xdg-desktop-portal-wlr: xdg-desktop-portal backend |
We see some suggestions for packages.
The package “polkit” has already been installed (see above), so we should be fine.
Let’s also install “foot” to be able to open a terminal with the default configuration and also “wmenu” and “dmenu” (see the output above about these programs):
1 |
sudo pacman -S foot wmenu demnu |
Now, we can start “sway” from the command line.
There’s not much with the default configuration: just the workspace indicator (top-left) and the date and time (top-right), not even a wallpaper (we’ll deal with that in a minute).
We can start a terminal (“foot”) with SUPER+ENTER.
To start an application with the application launcher (by default wmenu/dmenu), for example, “firefox” (if installed) we use SUPER+D and start typing in the prompt appearing in the top left corner; a few letters should be enough til you get to the desired program (and press ENTER to launch it).
Of course, the windows are tiled:
NOTE: the SUPER (i.e., the “Window key”) is the default “mod” modifier for keybindings, but you can change it to something else if you want (e.g., “Alt”).
We can switch workspaces with SUPER+<workspace number>, start other terminals there:
We can focus windows with SUPER+<arrow keys> and move a window to another workspace with SUPER+SHIFT+<workspace number>—and close windows with SUPER+SHIFT+Q.
To move the current window and change its position in the tiling, use SUPER+SHIFT+<arrow keys> (instead of arrow keys, you can also use the H, J, K, and L as in Vim):
Let’s install the package “swaybg” (see the output above; that’s the “Wallpaper tool for sway”):
1 |
sudo pacman -S swaybg |
Now, let’s reload sway with SUPER+SHIFT+C and…
We have the wallpaper!
It’s time to start customizing the configuration.
Let’s create the directory for the configuration file and start from the default one:
1 2 |
mkdir -p ~/.config/sway cp /etc/sway/config ~/.config/sway/ |
Now, we can edit the “~/.config/sway/config” file. (note that the file ends with “include /etc/sway/config.d/*”, which properly sets a few environment variables and makes them available to systemd).
The first thing I will customize is the keyboard layout: I have an Italian keyboard, so I have to specify that (the default is an American layout). I’ll add this section somewhere in the config file (e.g., near the comments about other input configurations):
1 2 3 4 5 |
# right Ctrl to switch input type:keyboard { xkb_layout it,us xkb_options grp:rctrl_toggle } |
This will give me an Italian layout by default, and I can switch to an American layout by pressing the right CTRL.
Save the file, reload with SUPER+SHIFT+C, and experiment with the keyboard layouts.
Let’s change the application launcher, which is not very useful in its current shape. Let’s use the Wayland version of Rofi.
1 |
sudo pacman -S rofi-wayland |
Then, let’s open the Sway config file and change the setting of the $menu as follows:
1 |
set $menu "rofi -show drun -show-icons" |
Reload Sway and now pressing the SUPRT+D will get us a much nicer application launcher (just start typing to filter the entries):
Let’s install a file manager, like Nemo.
1 |
sudo pacman -S nemo |
Then, we can create a shortcut for opening the file manager; let’s open the Sway config file, define a variable for the file manager (it will make it easier in the future to switch to another file manager, for example) and a key binding, e.g., SUPER+SHIFT+ENTER:
1 2 3 4 |
set $filemanager nemo ... # Start a filemanager bindsym $mod+Shift+Return exec $filemanager |
Moreover, I prefer Alacritty as a program for terminal:
1 |
sudo pacman -S alacritty |
Then, we just have to change the “$term” definition in the Sway config file: change the line “set $term foot” to
1 |
set $term alacritty |
Now, we need an Authentication Agent, which pops up a window asking you for a password whenever an app wants to elevate its privileges. I prefer the KDE one:
1 |
sudo pacman -S polkit-kde-agent |
And start it when Sway starts; so in the Sway configuration file:
1 2 |
### Autostart applications exec "/usr/lib/polkit-kde-authentication-agent-1" |
Since this is “exec”, not “exec_always”, you need to restart Sway, not simply reload it.
Now, if we run from a terminal a “systemctl” command that needs superuser privileges, we get the pop-up dialog asking for a password:
The configuration file already contains a commented section for locking and screensaver:
1 2 3 4 5 6 7 8 9 10 11 12 |
### Idle configuration # # Example configuration: # # exec swayidle -w \ # timeout 300 'swaylock -f -c 000000' \ # timeout 600 'swaymsg "output * power off"' resume 'swaymsg "output * power on"' \ # before-sleep 'swaylock -f -c 000000' # # This will lock your screen after 300 seconds of inactivity, then turn off # your displays after another 300 seconds, and turn your screens back on when # resumed. It will also lock your screen before your computer goes to sleep. |
So, let’s install the involved programs (also mentioned above when we installed Sway):
1 |
sudo pacman -S swayidle swaylock |
Uncomment the “exec” command; remember that we need to restart Sway to have that mechanism in action. (Of course, you have to wait for 300 seconds). I’m not covering customization of the lock screen and the like here.
We can also set a key binding to lock the screen manually. I usually use SUPER+L; note that this is already bound as a combination to move on the left window (remember the Vim keybindings above?); so, first, I have to uncomment the corresponding bindings (I uncomment them all because I’m not using them: I prefer arrow keys) and add mine:
1 2 3 4 5 6 7 |
# lock the screen bindsym $mod+l exec swaylock -f -c 000000 ... #bindsym $mod+$left focus left #bindsym $mod+$down focus down #bindsym $mod+$up focus up #bindsym $mod+$right focus right |
Let’s install some of the optional packages suggested above when installing Sway (in particular, the “xorg-xwayland” will allow us to run also X applications):
1 2 3 4 |
sudo pacman -S \ xorg-xwayland \ xdg-desktop-portal-gtk \ xdg-desktop-portal-wlr |
That’s all for this first tutorial part; stay tuned for more to come 🙂