Setting up the sway window manager on Fedora

Sometimes during a critical activity, working with overlapping windows becomes counterproductive. You might find a tiled window manager like sway to be a good alternative.

Sway is a tiling Wayland compositor. It has the advantage of compatibility with an existing i3 configuration, so you can use it to replace i3 and use Wayland as the display protocol.

Installing sway

To setup sway, open a new terminal and type the following command

sudo dnf install sway

Once the installation is completed, log out of your user session. At the login screen, select your user account. Before you enter your password, choose Sway from the menu, as shown in the following image.

After login, your desktop looks like this:

Configuration

To begin configuration, copy the default config into your user directory. Do that using the following commands.

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

Sway is highly configurable. It’s suggested you read the project’s wiki page to fine tune your settings. For example, to change the keyboard layout, open a new terminal and run this command:

$ swaymsg -t get_inputs
[george@mrwhite ~]$ swaymsg -t get_inputs
 Input device: VirtualPS/2 VMware VMMouse
   Type: Mouse
   Identifier: 2:19:VirtualPS/2_VMware_VMMouse
   Product ID: 19
   Vendor ID: 2
   Libinput Send Events: enabled
 Input device: VirtualPS/2 VMware VMMouse
   Type: Mouse
   Identifier: 2:19:VirtualPS/2_VMware_VMMouse
   Product ID: 19
   Vendor ID: 2
   Libinput Send Events: enabled
 Input device: AT Translated Set 2 keyboard
   Type: Keyboard
   Identifier: 1:1:AT_Translated_Set_2_keyboard
   Product ID: 1
   Vendor ID: 1
   Active Keyboard Layout: Portuguese (Brazil)
   Libinput Send Events: enabled

Copy the identifier keyboard code. Open your ~/.config/sway/config file with your text editor and edit the configuration accordingly:

## Input configuration
input "1:1:AT_Translated_Set_2_keyboard" {
  xkb_layout br
}

Save the settings. To reload the configurations, press Super+Shift+c. (Typically the Super key is mapped to the logo key on a PC.)

Waybar

Sway’s default status bar may not have all the functions you want. Fortunately Waybar is a good replacement. To install, run the follow commands. (Note, however, that COPR is not an official Fedora repository and not supported by the Fedora Project.)

sudo dnf copr enable alebastr/waybar 
sudo dnf install waybar 

Open your ~/.config/sway/config file. Edit the bar configuration like this:

bar {
  swaybar_command waybar
}

Reload the configuration and you’ll now see the waybar in action, as shown below.

To customize the waybar, you can visit this wiki page for more details and ideas.

Alacritty

Alacritty is a terminal emulator that uses the GPU for rendering, and a good replacement for urxvt. To install run the following lines

sudo dnf copr enable pschyska/alacritty
sudo dnf install alacritty

To enable it as default terminal emulator edit your ~/.config/sway/config. Change this line:

set $term urxvt256c-ml

To:

set $term alacritty

Reload your configuration.

When you open a new terminal with Super+C, alacritty will be open as seen in the following image:


Photo by Ivan Vranić on Unsplash.

Using Software

18 Comments

  1. Many thanks for this. I’ve been wanting to switch “i3” to “sway” for a while but could never get around to the research. Quick and easy, good job!

  2. RMPR

    Do you know why Fedora doesn’t have sway related packages inside the official repository, I don’t really like to add COPR because when they are too much they slow down dnf ? I had the same problem with i3 and had to rely on COPR, and I think one thing you should add is since sway uses wayland only two display manager actually support it : GDM and SDDM, I had issues because I was using another display manager.

  3. Davide

    better than i3wm, but there are still problems with tray icons, once installed I have many red smiles

  4. ewew

    is possible show desktop and terminal?
    for example on desktop I have calendar, information about cpu network, and seting my network.

    second question are speed. This are faster than my text terminal?

    • Yorozuya

      You can show a background and in a future when conky has support for Wayland, time resources usage, network… But I use waybar to show that

  5. decko

    Can Kitty be a good substitute to alacritty?

  6. David

    Having to always enable copr stuff is my biggest gripe with Fedora. I wish things like Alacritty were available in the official repos.

  7. The2gNetwork

    I’m using the xfce spin.
    Lightdm won’t let me select a different window manager.
    Which login manager is that?

  8. hammerhead corvette

    Bigh thumbs up for sway !

  9. Bob

    It would be great if your article about a tiling window manager had a screenshot of some tiled windows!

  10. Gianluca

    I also recommend to take a look at the https://extensions.gnome.org/extension/28/gtile/ extension for Gnome for those who need more control over windows arrangement without sacrificing the simplicity and usability of Gnome Shell.

  11. Alex

    I wish there were more posts like that! It really helped me configuring an i3 like desktop without taking a whole weekend figuring out the basics

  12. You can also do:
    input “*” {
    xkb_layout br
    }

    It’s handy if you don’t plan on using keyboards with different layouts.
    In my case, I am using the same sway config file across my different laptops. Saves me get inputs extra steps

  13. Rich

    Thanks for this. I liked the idea of using Sway with a minimal install and without Gnome. But found you need to install mesa dri drivers to get Sway to start using Fedora netinstall (minimal installation, Gnome not installed)

    sudo dnf install mesa-dri-drivers

Comments are Closed

The opinions expressed on this website are those of each author, not of the author's employer or of Red Hat. Fedora Magazine aspires to publish all content under a Creative Commons license but may not be able to do so in all cases. You are responsible for ensuring that you have the necessary permission to reuse any work on this site. The Fedora logo is a trademark of Red Hat, Inc. Terms and Conditions