Premise

So I had a Linux laptop for a bit now. On my main desktop workstation I used to have Arch, but to help my wife's recent 3d endevours I installed PopOS instead, which is more user friendly, and most importantly, is somewhat officially supported by Autodesk. Where by "officially supported" I mean: there's a 13 steps guide on their website documenting the commands to run to get it to work, including setting up correctly their beautiful Licensing tools (something that I tried to on Arch without success, mostly due to the horrible error messages spit out by the AdskLicensingHelper CLI).

Due to this loss, the amount of tinkering I feel the need to do on my laptop has grown exponentially. Which eventually lead me into the beautiful 🐇 hole of tiling window managers..

A hole I have been carefully avoiding for a while, since whenever I do 3d stuff I tend to have a lot of floating windows, so tiling window managers don't really solve any problems there. However, the promotion of this laptop to a pure dev machine meant that hell could finally break loose..

Getting started

As always, for a more in-depth guide I recommend to follow the official website (https://swaywm.org/ and https://github.com/swaywm/sway/wiki, https://github.com/swaywm/sway/wiki/Useful-add-ons-for-sway) and the Arch wiki page (even if you're not on Arch). However, if you're a bit in a rush and just want to get things going and learn the basics, you might find this post useful!

To install sway on Arch, I installed these packages:

pacman -Sy sway
pacman -Sy sway-bg # required to set a bg, see https://github.com/swaywm/sway/issues/4164
pacman -Sy wofi    # this is my custom app launcher

Now the fun begins.

To run a Sway session, since I don't have a login manager, I just have this in my bashrc:

start-sway(){
  exec dbus-run-session sway
}

Final look

I had sway for a few days, so there's plenty of tinkering left to do. Things currently look like this, with 'wofi' in the center, 'emacs' on the left and 'wezterm' on the right:

Configuration

As per the wiki, you can copy the default config to get up and running with some basics:

mkdir -p ~/.config/sway
cp /etc/sway/config ~/.config/sway/

NOTE: To hot-reload your Sway config after you made some changes to it you can press Prefix + Shift + C.

The default prefix (or 'mod' key) is the 'logo button' (the windows keys probably, since I can't' think of Linux laptops that has a 🐧 key).

I've set it to be 'Alt' instead via this entry:

set $mod Mod1

Launching apps

To open your favourite terminal emulator, you can just type Prefix + Enter. This is because the default config has this entry:

bindsym $mod+Return exec $term

To set your favour terminal, you can add this entry in the config (in my case it's WezTerm) :

set $term wezterm 

To open your default application launcher (in my case, wofi) it's Prefix + D.

You can set the command required by adding this entry:

set $menu wofi --show drun exec

To move to the virtual desktop N, you can type Prefix + 1,2,3..N

To move across windows, you can use either Prefix+h,j,k,l or Prefix+up,down,left,right arrow.

The vim-mode style is achieved thanks to these entries:

set $left h
set $down j
set $up k
set $right l

To tell sway that the next window should be a horizontal split, you'll type Prefix+v. For a vertical split, Prefix+b.

To close a window, press Prefix+q.

Modes

  • Prefix + w -> Enter Tabbed mode
  • Prefix + e -> Enter Tiling mode
  • Prefix + f -> Enter Full Screen mode

Moving windows

To move a window to workspace N, you can use $mod+Shift+{some-number} , e.g.: Alt+Shift+1.

This is achieved by these entries in the config:

bindsym $mod+Shift+1 move container to workspace number 1
bindsym $mod+Shift+2 move container to workspace number 2
# ..and so on..

Status bar

This is one of the bits I enjoyed the most. You can basically run any command you want, and display its result in the status bar!

For mine, I have set it up like this :

bar {
    position top

    # When the status_command prints a new line to stdout, swaybar updates.
    status_command while ~/.config/sway/status.sh; do sleep 60; done

    colors {
        statusline #ffffff
        background #323232
        inactive_workspace #32323200 #32323200 #5c5c5c
    }
}

Where ~/.config/sway/status.sh is like this:

uptime_formatted=$(uptime | cut -d ',' -f1 | awk '{print $3 " " $4}')

date_str=$(date "+%a %F %H:%M")

battery_info=$(upower --show-info $(upower --enumerate))
battery_is_charging=$(echo "$battery_info" | grep icon-name | grep 'charging' -c)
battery_is_low=$(echo "$battery_info" | grep icon-name | grep 'battery-low-symbolic' -c)

if [ $battery_is_low = 1 ]; then
    battery_icon=đŸĒĢ
elif [ $battery_is_charging = 1 ]; then
    battery_icon=🔌
fi

battery_percent=$(echo "$battery_info" | grep percentage | awk '{print $2}')

echo "$(hostname), up since $uptime_formatted -- battery: $battery_percent $battery_icon -- $date_str"

This results in a status bar like this:

Screengrabs

I found https://github.com/Gustash/sway-screenshot to be a tiny neat utility.

On arch, it can be installed via the AUR helpers:

paru sway-screenshot

The docs on how to use it with Sway are included in their Readme, so I won't duplicate them here.

How about volume ?

I haven't (yet) found a great way to get visual feedback whenever I change volume. But these entries work fine to use the function keys on my keyboard to lower/raise/mute the volume:

bindsym XF86AudioRaiseVolume exec pactl set-sink-volume 0 +5%
bindsym XF86AudioLowerVolume exec pactl set-sink-volume 0 -5%
bindsym XF86AudioMute exec pactl set-sink-mute 0 toggle
bindsym XF86AudioMicMute exec pactl set-source-mute 0 toggle

One workaround is to install pavucontrol and run its GUI directly whenever I need to have visual feedback:

pacman -Sy pavucontrol 

How about more visual pizzazz?

That's a job for swayfx, a fork of sway that:

[...] ditches the simple wlr_renderer, and replaces it with our fx_renderer, capable of rendering with fancy GLES2 effects.

On arch it's packaged on the AUR:

paru swayfx

For example, I have set my windows to have a blurred blackground and rounded corners:

# Swayfx stuff
smart_corner_radius enable
corner_radius 10

## blur
blur enable
blur_xray enable
blur_passes 4
blur_radius 4