Working on Fedora Sway Spin

Fedora now has a Sway Spin that comes with Sway, an i3-compatible Wayland compositor, preinstalled and configured.

· 2 min read
Working on Fedora Sway Spin

Sway is an i3-compatible Wayland compositor. It is designed to be a drop-in replacement for i3 window manager, but works under Wayland environment.

Installation

Fedora now has a Sway Spin that comes with sway preinstalled and configured.
Alternatively, it could be installed on Fedora Workstation and other spins.

sudo dnf install "@Sway Desktop"
sudo dnf insatll "@Sway Window Manager (supplemental packages)" --allowerasing

Spin Bundled Components

Fedora Sway Spin comes with multiple components, including:

  • swaylock: Simple screen locker.
  • waybar: Highly customizable Wayland bar for Sway and Wlroots based compositors.
  • rofi: Highly-configurable and lightweight notification daemon.
  • dunst: Highly-configurable and lightweight notification daemon.
  • kanshi: A Dynamic display configuration tool.

Sway Window Manager

The default Sway configuration is at /etc/sway/config. On Fedora Sway Spin, it reads additional configurations from 3 locations:

  • /usr/share/sawy/config.d
  • /etc/sway/config.d
  • ~/.config/sway/config.d ($XDG_CONFIG_HOME/sway/config.d to be precise)

Kanshi

Fedora Sway Spin bundles kanshi, which is a dynamic display configuration tool.

Its configuration file is placed at ~/.config/kanshi/config. Multiple profiles could be defined in the configuration, one of which will be enabled if all of the listed outputs are connected.

Adding the first profile could be very straight forward. List all outputs recognized by sway:

swaymsg -t get_outputs

Take mine as an example, I have eDP-1 which is the laptop internal display, along with DP-1 and DP-2 which are  connected to my dock.
I am going disable the internal display and set the 2 external ones to side by side with scale:

profile {
    output eDP-1 enable scale 1.5
}

profile {
  output eDP-1 disable 
  output DP-1 enable mode 3840x2160@60 position 0,0 scale 2.0
  output DP-2 enable mode 3840x2160@60 position 1920,0 scale 2.0
}

Note that I am using 2X scaling (scale 2.0), so the position should be 3840 / 2 = 1920.
Finally let Kanshi start with Sway.
Add a Sway configuration segment to ~/.config/sway/config.d/10-kanshi.conf:

exec_always {
  pkill kanshi
  kanshi &
}

Tweaks and Customization

Override Default Terminal Emulator

I personally perfer Terminator over the default foot. So I added a new segmented configuration file at ~/.config/sway/config.d/10-preferred-applications.conf:

set $term terminator
bindsym --no-warn $mod+Return exec $term

Map Caps Lock to Control

I personally more adopted to Unix keyboard layout, especially no Caps Lock but a left control.
Add a new configuration to ~/.config/sway/config.d/10-input-keyboard.conf:

input "type:keyboard" {
	xkb_options caps:ctrl_modifier
}

Touchpad Tweaks

By default, there is no natural scrolling and tap to click. Add a new configuration to ~/.config/sway/config.d/10-input-touchpad.conf:

input "type:touchpad" {
       dwt enabled
       tap enabled
       natural_scroll enabled
       middle_emulation enabled
}

Software Integration

Most of the software work under Wayland or XWayland out of the box. But some of them still need fine-tuning.

Chromium

Chromium defaults to auto-select platform backend, which might lead to falling back to X. Visit chrome://flags and select Wayland for #ozone-platform-hint to indicate Chromium to use Wayland.

Electron in Flatpak

Some Flatpaks come with Wayland disabled by default because it might cause issues on non-HiDPI displays. When using a HiDPI monitor with scaling, however, this results in blurred user interface. To fix this, expose wayland socket to the application:

flatpak override --socket=wayland <APP_ID>

Alternatively, this could also be done in a GUI way via Featseal.

More to Read