Sway in Arch Linux: getting started

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:

The output shows:

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):

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”):

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:

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):

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.

Then, let’s open the Sway config file and change the setting of the $menu as follows:

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.

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:

Moreover, I prefer Alacritty as a program for terminal:

Then, we just have to change the “$term” definition in the Sway config file: change the line “set $term foot” to

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:

And start it when Sway starts; so in the Sway configuration file:

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:

So, let’s install the involved programs (also mentioned above when we installed Sway):

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:

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):

That’s all for this first tutorial part; stay tuned for more to come 🙂

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.