Sway Power-User Configuration
Configure Sway end-to-end: i3-compatible bindings, Waybar status bar, swaylock screen locking, swayidle with idle-hints, and grim/slurp screen capture.
Before you start
- ▸A working Linux install with systemd and a TTY or display manager login
- ▸A user account with sudo privileges
- ▸A GPU with Wayland/DRM support (Intel, AMD, or Nvidia with kernel 6.1+ drivers)
- ▸Basic familiarity with editing text config files in a terminal
Sway is a Wayland compositor that speaks the i3 config language almost verbatim. If you migrated from i3, most of your ~/.config/i3/config works unchanged. If you're starting fresh, you get a tiling compositor with solid HiDPI support, no Xorg dependency, and a mature ecosystem built around wlr-protocols. This guide wires together a complete daily-use setup: Waybar for the status bar, swaylock for screen locking, swayidle for automatic idle actions, and grim/slurp for screen capture.
Installing Sway and Core Utilities
Debian / Ubuntu (22.04+)
sudo apt install sway waybar swaylock swayidle swaybg \
grim slurp wl-clipboard mako-notifier fonts-font-awesome
Fedora 38+
sudo dnf install sway waybar swaylock swayidle swaybg \
grim slurp wl-clipboard mako fonts-awesome-cron
Arch Linux
sudo pacman -S sway waybar swaylock swayidle swaybg \
grim slurp wl-clipboard mako ttf-font-awesome
Log out of your current session. At the display manager or TTY login, select Sway as the session type, or run sway from a bare TTY.
Base Sway Configuration
Sway reads ~/.config/sway/config. Copy the system default first, then edit it:
mkdir -p ~/.config/sway
cp /etc/sway/config ~/.config/sway/config
The file is i3-compatible syntax. Key settings to tune immediately:
# Set modifier key (Mod4 = Super/Win, Mod1 = Alt)
set $mod Mod4
# Preferred terminal and app launcher
set $term foot
set $menu wofi --show drun --prompt 'Run'
# Font for window titles
font pango:JetBrains Mono 10
# Natural scrolling and tap-to-click on touchpad
input type:touchpad {
tap enabled
natural_scroll enabled
dwt enabled
}
# Per-output resolution and scale (adjust to your monitor name)
output eDP-1 resolution 2560x1600 scale 1.5
# Wallpaper
output * bg /usr/share/backgrounds/sway/Sway_Wallpaper_Blue_1920x1080.png fill
Find your output name with swaymsg -t get_outputs and your input device name with swaymsg -t get_inputs.
Replacing the Default Bar with Waybar
Comment out the built-in bar { … } block in your sway config and launch Waybar instead:
# In ~/.config/sway/config — replace the bar block with:
exec_always --no-startup-id waybar
Create Waybar's config directory and start with the packaged example:
mkdir -p ~/.config/waybar
cp /etc/xdg/waybar/config ~/.config/waybar/config
cp /etc/xdg/waybar/style.css ~/.config/waybar/style.css
A minimal, functional ~/.config/waybar/config that covers the essentials:
{
"layer": "top",
"position": "top",
"modules-left": ["sway/workspaces", "sway/mode"],
"modules-center": ["clock"],
"modules-right": ["pulseaudio", "network", "battery", "tray"],
"clock": {
"format": "{:%a %d %b %H:%M}",
"tooltip-format": "{:%Y %B}\n{calendar}"
},
"battery": {
"states": { "warning": 20, "critical": 10 },
"format": "{capacity}% {icon}",
"format-icons": ["", "", "", "", "", "", ""]
},
"network": {
"format-wifi": "{essid} ({signalStrength}%) ",
"format-ethernet": "{ipaddr} ",
"format-disconnected": "Disconnected "
},
"pulseaudio": {
"format": "{volume}% {icon}",
"format-muted": "",
"format-icons": { "default": ["", "", ""] },
"on-click": "pavucontrol"
}
}
Reload Sway ($mod+Shift+c) to see Waybar replace the default bar.
Screen Locking with swaylock
swaylock is a Wayland-native screen locker. Create ~/.config/swaylock/config:
color=1e1e2e
ring-color=89b4fa
key-hl-color=a6e3a1
text-color=cdd6f4
inside-color=1e1e2e
font=JetBrains Mono
show-failed-attempts
ignore-empty-password
Test it immediately to verify your login password works before automating it:
swaylock --config ~/.config/swaylock/config
Add a keybinding in your sway config:
bindsym $mod+shift+l exec swaylock --config ~/.config/swaylock/config
Automatic Idle Actions with swayidle
swayidle watches for compositor idle signals and runs commands at defined timeouts. It also hooks into systemd's logind to handle lid close and system sleep. Add this to your sway config:
exec swayidle -w \
timeout 300 'swaylock --config ~/.config/swaylock/config' \
timeout 360 'swaymsg "output * dpms off"' \
resume 'swaymsg "output * dpms on"' \
before-sleep 'swaylock --config ~/.config/swaylock/config' \
lock 'swaylock --config ~/.config/swaylock/config'
- timeout 300: lock after 5 minutes of idle.
- timeout 360: turn off displays 1 minute after locking.
- resume: turn displays back on when activity resumes.
- before-sleep: lock before the system suspends (requires logind integration).
- lock: respond to
loginctl lock-sessionfrom other processes.
The -w flag tells swayidle to wait for swaylock to grab the input before the display powers off, preventing a brief flash of the unlocked desktop.
Idle Inhibit for Full-Screen Applications
Sway can automatically suppress idle when a window is full-screen — essential for video playback. Add to your sway config:
# Inhibit idle when any window is fullscreen
for_window [class=".*"] inhibit_idle fullscreen
for_window [app_id=".*"] inhibit_idle fullscreen
For finer control, applications can set the zwp_idle_inhibit_unstable_v1 protocol hint directly (Firefox and mpv do this natively on Wayland). You can also manually inhibit idle for the focused window:
bindsym $mod+shift+i inhibit_idle open
Screen Capture
Full-Screen and Region Screenshots
grim captures Wayland output; slurp provides interactive region selection. Add these bindings:
# Full screenshot to ~/Pictures
bindsym Print exec grim ~/Pictures/screenshot-$(date +%Y%m%d-%H%M%S).png
# Region screenshot — click-drag to select area
bindsym $mod+Print exec grim -g "$(slurp)" \
~/Pictures/screenshot-$(date +%Y%m%d-%H%M%S).png
# Region screenshot piped directly to clipboard
bindsym $mod+shift+Print exec grim -g "$(slurp)" - | wl-copy
Screen Recording
Install wf-recorder for GPU-accelerated Wayland screen recording:
# Arch
sudo pacman -S wf-recorder
# Fedora
sudo dnf install wf-recorder
# Ubuntu/Debian (may need PPA or build from source on older releases)
sudo apt install wf-recorder
# Record selected region to file (Ctrl+C to stop)
bindsym $mod+r exec wf-recorder -g "$(slurp)" -f ~/Videos/record-$(date +%Y%m%d-%H%M%S).mp4
bindsym $mod+shift+r exec pkill -SIGINT wf-recorder
Verification
After editing, reload the config without logging out:
swaymsg reload
Check that all exec'd processes started correctly:
swaymsg -t get_tree | grep -E 'waybar|swayidle'
journalctl --user -b | grep -E 'sway|waybar|swayidle|swaylock'
Trigger the lock manually and confirm display power-off follows roughly 60 seconds later:
loginctl lock-session
Troubleshooting
swaylock shows a black screen and accepts no input
This usually means swaylock isn't installed setuid or PAM isn't configured. On Arch, ensure /etc/pam.d/swaylock exists (the package creates it). On Debian/Ubuntu, reinstall the package to trigger the postinst script.
Waybar doesn't show after reload
Check for a conflicting second instance: pkill waybar then swaymsg reload. Also validate your JSON config with waybar --log-level debug 2>&1 | head -40 — a trailing comma in JSON will silently prevent startup.
Screen doesn't turn off during idle
Confirm swayidle is running: pgrep -a swayidle. If an application holds an idle inhibitor (check with swaymsg -t get_tree | grep inhibit), DPMS will be suppressed. Also verify the compositor has DPMS support enabled — it's on by default, but some GPU drivers on older kernels can interfere.
grim captures a blank image on multi-monitor setups
Specify the output explicitly: grim -o eDP-1 screenshot.png. List available outputs with swaymsg -t get_outputs | grep name.
Frequently asked questions
- Can I use my existing i3 config file with Sway?
- Mostly yes. Sway implements nearly all of i3's config syntax. The main exceptions are X11-specific options like xss-lock, compton/picom, and anything referencing class= instead of app_id=. Replace those with Wayland equivalents and you're set.
- Why does swayidle not lock my screen before suspend?
- The before-sleep hook requires systemd-logind. Confirm your system uses logind (loginctl status) and that swayidle was started with -w. Without -w, the system can suspend before swaylock grabs the session.
- How do I take a screenshot of just the focused window?
- Use grim combined with swaymsg to get the focused window's geometry: grim -g "$(swaymsg -t get_tree | jq -r '.. | select(.focused?) | .rect | "\(.x),\(.y) \(.width)x\(.height)"')" screenshot.png. This requires jq.
- Waybar shows my battery percentage but not the icon — how do I fix it?
- The icon glyphs require a Nerd Font or Font Awesome to be installed and selected. Install ttf-font-awesome (or a Nerd Font), then reference it in the Waybar style.css font-family property alongside your regular font.
- Does Sway support variable refresh rate (VRR / FreeSync)?
- Yes, since Sway 1.7 on capable hardware. Add adaptive_sync on to the relevant output block in your config: output eDP-1 adaptive_sync on. Not all drivers expose the required kernel atomic property.
Related guides
Linux Clipboards Explained (+ Clipboard Managers)
Learn the difference between Linux's PRIMARY and CLIPBOARD selections, use xclip, xsel, and wl-clipboard from the terminal, and manage history with GPaste or Klipper.
Configure LibreOffice for Daily Use
Configure LibreOffice for daily use: set default save formats for MS Office interop, tune autosave, install fonts, and add productivity extensions.
Configure the Touchpad and Multitouch Gestures
Configure Linux touchpad behavior and multitouch gestures using libinput, libinput-gestures, and native GNOME and KDE Plasma settings on both Wayland and X11.
Wayland vs X11: How to Choose and Configure Each
Know when to run Wayland or X11, how to check your current session, switch at login with GDM/SDDM/LightDM, and handle NVIDIA and XWayland edge cases.