Sway Window Manager: A Beginner’s Guide to Getting Started

Introduction

Sway is a popular tiling window manager designed for Wayland. It’s a spiritual successor to i3, offering similar functionality but with modern Wayland support. Whether you’re seeking a lightweight setup or wanting to customize your workflow, Sway provides unparalleled flexibility. In this post I will guide you through getting started with Sway, from setting it up in a virtual machine to configuring it for your perfect setup.

If you’re new to the concept of window managers, I recommend starting with my post, What is a Window Manager? A Beginner’s Guide to Linux WMs, to understand the basics before diving into Sway.

Wayland is a modern display server protocol, and Sway fully embraces it. To understand how Wayland compares to X11, see my post on Exploring X11, Wayland, and GNOME vs KDE.


What is Sway?

Sway is a tiling window manager that works exclusively with Wayland, a newer display protocol designed to replace X11. It’s built to be a drop-in replacement for i3, meaning you can use many i3 configurations directly with Sway. With its active development and strong community, Sway is ideal for users who value speed, simplicity, and customization.

Sway is just one of many excellent window managers available today. If you’re interested in exploring other options, including X11 and Wayland-based managers, check out my Comprehensive Guide to Window Managers.

Key Features of Sway:

  • Full compatibility with i3 configs.
  • Native Wayland support for improved performance and security.
  • Lightweight and efficient for older hardware or minimal systems.
  • Extensive customization via a single configuration file.

How to Get Started with Sway in a Virtual Machine

Step 1: Setting Up the Virtual Machine

To try Sway without affecting your main system, use a virtual machine. Here’s how to do it:

  1. Download an ISO with Sway Preinstalled:
    • Recommended distros:
      • Fedora (with Sway Spin).
      • Arch Linux (minimal base with manual Sway installation).
    • Alternatively, use a minimal ISO and install Sway manually.
  2. Install Your VM:
    • Use virtualization software like VirtualBox, VMware, or QEMU/KVM.
    • Allocate resources:
      • 2GB+ RAM.
      • 2 CPU cores.
      • 20GB disk space.
  3. Boot into Sway:
    • Start your VM and log in.
    • If Sway is installed but not started, run sway from a terminal.

Step 2: Accessing Project Resources

Before diving into configuration, familiarize yourself with Sway’s official resources:

Make sure to read the documentation through, especially if you are new to window managers and editing config file, I usually keep the documentation open when I am working on my VM, so I can reference it.


First Login: Understanding Sway’s Basics

When you first log into Sway, you’ll be greeted by a minimal and efficient workspace, mine here has been edited, but it will be very similar. This can feel a bit stark compared to traditional desktop environments, but it’s designed to give you total control and flexibility. Here’s what to expect and how to get started:


What You’ll See

  • A blank, minimal desktop: There are no taskbars, desktop icons, or wallpapers by default.
  • Keyboard-driven navigation: Sway relies heavily on keyboard shortcuts for window management and navigation.
  • Waybar (if installed): If you’ve installed Waybar, you’ll notice a small, customizable taskbar at the top or bottom. It shows system stats like CPU usage, RAM, and network activity.

Pro Tip: If Waybar is missing, consider installing it for a better overview of your system.


What to Do First

  1. Open a Terminal:
    • Press Mod+Enter (where Mod is typically the Super/Windows key) to open a terminal.
    • From here, you can launch applications, edit configuration files, or install additional tools.
  2. Explore the Default Keybindings:
    Familiarizing yourself with the keybindings is critical for navigating and using Sway effectively.
    • Mod+Q → Closes the currently focused window.
    • Mod+Shift+E → Exits Sway gracefully.
    Resource: Visit the Official Sway Keybindings Documentation to learn more.
  3. Understand the Tiling Layout:
    • By default, windows are automatically tiled, making efficient use of your screen space.
    • Use the Mod key with arrow keys or shortcuts to adjust the layout and move between windows.

First Steps After Logging In

Here’s a checklist to get started:

  • Edit the Configuration File:
    Sway’s behavior is controlled by its configuration file, usually located at ~/.config/sway/config. Open it with your preferred text editor: vim ~/.config/sway/config Modify keybindings, default applications, and other settings to match your preferences.
  • Set a Wallpaper:
    Install a wallpaper tool like swaybg or feh to personalize your desktop. For example, you can run: swaybg -i /path/to/your/wallpaper.jpg
  • Test Applications:
    Launch common Wayland-compatible applications (e.g., foot, alacritty, or firefox) to ensure your setup is functional.

What to Do if You Feel Overwhelmed

  • Start Small: Focus on understanding a few basic keybindings like opening/closing terminals and switching windows.
  • Use Resources: The Sway Wiki and Arch Wiki are invaluable for troubleshooting and advanced setup.
  • Find Inspiration: Browse r/unixporn for inspiration and ideas on how to customize your setup.

By taking it one step at a time, you’ll quickly gain confidence in using Sway and appreciate the freedom it offers.


Finding Your Style

Customize Sway to suit your workflow:

  • Minimalist Setup: Focus on keyboard shortcuts and remove distractions.
  • Feature-Rich Setup: Add bars, launchers (like Rofi), and graphical apps.

Examples of Configs:


Conclusion

Sway offers unparalleled freedom to create a desktop environment tailored to your needs. From its lightweight tiling layout to its Wayland compatibility, it’s perfect for power users and minimalists alike. Dive into Sway, explore its configurations, and build a workspace that inspires productivity.

Have questions or need help? Drop a comment or reach out to me—I’d love to discuss Sway setups or help troubleshoot your journey!



Leave a Reply

Your email address will not be published. Required fields are marked *