How to Install and Configure Sway (Wayland) on Arch Linux

How to Install and Configure Sway (Wayland) on Arch Linux

Sway is a modern, tiling window manager built for Wayland, designed to be a drop-in replacement for the popular i3 window manager, which is based on X11. If you’re already comfortable with i3, transitioning to Sway is fairly straightforward, but even newcomers to tiling window managers can find Sway to be a lightweight and efficient solution for a minimal, keyboard-driven desktop environment.

In this guide, we’ll walk through the steps required to install and configure Sway on Arch Linux. We’ll also touch on Wayland fundamentals, session startup, display configuration, and tips for enhancing your Sway setup.


Why Choose Sway?

Before diving into the technical aspects, it’s worth briefly covering what makes Sway and Wayland interesting options:

  • Wayland-native: Sway runs on Wayland, a newer display server protocol that addresses many limitations of X11, such as screen tearing, security flaws, and performance inefficiencies.
  • i3-compatible: Sway supports i3 configuration files, making it an excellent choice for i3 users wanting to move to Wayland.
  • Lightweight and performant: With no desktop environment bloat, Sway is ideal for users who want speed and control.
  • Modern features: Sway supports HiDPI scaling, multi-monitor layouts, and touch input more gracefully than many X11-based WMs.

Prerequisites

Before installing Sway, ensure your system is ready for a Wayland environment:

  • Arch Linux: This guide assumes you are using a base Arch Linux installation without a desktop environment.
  • Graphics Drivers: You must have Wayland-compatible graphics drivers installed. Most modern Intel, AMD, and NVIDIA (with recent open-source drivers) cards work well.
  • TTY Access: As you won’t have a graphical login manager initially, you should be comfortable using a TTY to log in and launch graphical sessions.

Graphics Driver Check

Ensure you have the appropriate driver installed. For example:

  • Intel: mesa
  • AMD: mesa and xf86-video-amdgpu
  • NVIDIA (open-source): mesa, nvidia, and nvidia-drm (with kernel mode setting enabled)

Use the following to verify:

lspci -k | grep -A 2 -E "(VGA|3D)"

Step 1: Install Sway and Dependencies

Install Sway using pacman:

sudo pacman -S sway

This will pull in core dependencies, including:

  • sway: the window manager itself
  • wlroots: the Wayland compositor library
  • wayland: the core protocol
  • xorg-xwayland: enables legacy X11 apps to run in a Wayland session
  • swaybg: sets the background image
  • swaylock and swayidle: for screen locking and idle management

You’ll also need some essential tools to make the environment usable:

sudo pacman -S xterm foot alacritty network-manager-applet dmenu wl-clipboard

Optional Packages

Depending on your needs, you might also want:

  • mako: a Wayland-native notification daemon
  • grim + slurp: screenshot tools
  • wofi: Wayland-native application launcher
  • pulseaudio / pipewire + pavucontrol: for audio control
  • waybar: a customizable status bar
  • thunar or pcmanfm: file managers
  • qt5-wayland / gtk3: for GUI applications

Step 2: Starting Sway

After installing the packages, simply log in to your user account and run:

sway

Sway will attempt to launch a Wayland session in your current TTY. If everything is working properly, you should see a tiling desktop with a terminal open and some basic instructions.

Exiting Sway

Use the default keybinding to quit:

Mod+Shift+e

The Mod key is usually set to the Super (Windows) key by default.


Step 3: Basic Configuration

Sway uses a configuration file located at:

~/.config/sway/config

If this file doesn’t exist, Sway will create it by copying the default from /etc/sway/config.

To create your personal config:

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

Open it in your text editor (e.g., nano, vim) and start customizing.

Keybindings

Sway supports nearly all i3 keybindings. Example keybindings you might want to modify:

set $mod Mod4
bindsym $mod+Return exec alacritty
bindsym $mod+d exec wofi --show run

Autostart Applications

To autostart programs, add exec lines at the end of the config:

exec nm-applet
exec mako
exec waybar

Setting Wallpaper

Use swaybg to set a wallpaper:

exec swaybg -i ~/Pictures/wallpapers/mountain.jpg -m fill

Step 4: Display Configuration

You can configure displays using the output directive in the config file:

output eDP-1 resolution 1920x1080 position 0,0
output HDMI-A-1 resolution 1920x1080 position 1920,0

To identify display names, use:

swaymsg -t get_outputs

For dynamic setup without editing the config file, consider using wdisplays or sway-output-config.


Step 5: Adding a Status Bar (Waybar)

Sway includes a basic status bar, but many users prefer Waybar for its flexibility.

Install it:

sudo pacman -S waybar

Then, in your Sway config:

exec waybar

Customize Waybar via ~/.config/waybar/config and style.css. Waybar supports modules for time, battery, audio, and even systemd.


Step 6: Lock Screen and Idle Handling

Use swaylock and swayidle for session security:

exec swayidle -w \
  timeout 300 'swaylock -f -c 000000' \
  timeout 600 'swaymsg "output * dpms off"' \
  resume 'swaymsg "output * dpms on"' \
  before-sleep 'swaylock -f -c 000000'

This configuration locks the screen after 5 minutes and turns off the display after 10 minutes.

You can install themes for swaylock or build it with image support (swaylock-effects) from the AUR.


Step 7: Application Compatibility (XWayland)

Sway supports legacy X11 applications via XWayland. Most standard Linux applications (Firefox, GIMP, VLC, etc.) run fine under Sway. However, some applications (e.g., Electron apps) may require environment variables to work correctly.

Add this to your .profile or .bashrc:

export MOZ_ENABLE_WAYLAND=1
export QT_QPA_PLATFORM=wayland
export GDK_BACKEND=wayland,x11

Wayland systems are moving towards PipeWire for audio management. Install it with:

sudo pacman -S pipewire pipewire-pulse wireplumber pavucontrol

Then enable and start:

systemctl --user enable --now pipewire pipewire-pulse wireplumber

You can use pavucontrol to adjust audio settings in a GUI.


Step 9: Useful Tools and Tips

  • Clipboard management: wl-clipboard
  • Screen capture: grim (whole screen), slurp (region)
  • Notifications: mako
  • Power management: udiskie, upower, acpid

Tiling Tips

  • Mod+Enter: open terminal
  • Mod+h/j/k/l: move focus
  • Mod+Shift+h/j/k/l: move window
  • Mod+f: toggle fullscreen
  • Mod+Shift+q: close window

Troubleshooting

Sway Doesn’t Start

  • Ensure you’re not running inside an X11 session.
  • Double-check that your GPU drivers are correctly installed.
  • Look at the logs: journalctl --user -b or ~/.local/share/sway/sway.log

Apps Look Ugly or Are Unscaled

  • Set proper environment variables for GTK/Qt (see above).
  • Configure HiDPI scaling if needed using:
output * scale 1.5

Flickering or Glitches

  • Try disabling hardware acceleration in problematic apps.
  • For NVIDIA users, ensure you’re using the open kernel modules and not the proprietary driver.

Conclusion

Sway is a fast, modern, and efficient tiling window manager that brings the power of Wayland to users who appreciate minimalism and keyboard-driven workflows. While the learning curve might be steep at first, especially for those coming from traditional desktop environments, the customization potential and responsiveness of Sway make it a compelling choice.

With the above steps, you should now have a functional and usable Sway environment on your Arch Linux system. From here, you can continue to tweak your setup, explore extensions and custom scripts, and build a workflow tailored exactly to your needs.