Welcome to the Wayland! đź”—

Posted by MĂ©dĂ©ric Ribreux 🗓 In blog/Debian/

#free software #computer #debian


It's been 7 years since I have installed and used everyday the i3 tile window manager. I have never used something else and it proved to be a good choice. I can now focus on keyboard commands and I don't have to handle windows positions on the screen anymore.

Whenever I am forced to use another old fashioned hand positionning window manager, I fulminate against it. I am just wasting time trying to focus on the program I need to use.

So far I have been very satisfied about my i3 usage. I just wrote a configuration file years ago and never had to look at it anymore. I just copy it to any new desktop computer that I own. It is a very stable window manager.

But last month, I found an alternative to i3 and I want to tell you how I use it as a replacement of i3. It is called sway and it aims to become an i3 replacement on the wayland graphical stack.

It's been years since everybody is using the Xorg graphical stack under GNU/Linux systems. It is very old as it predates the micro-computers era of the 80's. While being improved one small feet at a time, Xorg architecture has some drawbacks, inheritated from its beginnings.

Wayland has emerged a couple of years ago in order to completely get rid of the old Xorg stack principles. As an abstract, I can say that Wayland is the future of GNU/Linux desktop systems! For more information about the differences between Wayland and X, read this page.

Sway is a tiling window manager that works under Wayland. It aims to mimic i3, in its usage and even in it's configuration file. You just have to stick it into the right directory (~/.config/sway/config) and voila. Sway is coded in C and is very efficient, compact and fast. Even if it hasn't reach version 1.0, my tests have shown that it is perfectly usable everyday.

I have used it for a month at home, on my laptop and even on my office job workstation and it just does work.

How to install Sway under Debian?

First things first, you need to be under Debian Buster because compiling sway from sources requires some packages that do not exist in Debian Stretch (like meson).

Debian Packages Dependencies

# apt install libgles2-mesa-dev libdrm2 libdrm-dev libegl1-mesa-dev xwayland\
  libgbm-dev libinput-dev libsystemd-dev libcap-dev libxcb-composite0-dev \
  libxcb-image0-dev libxcb-icccm4-dev libxcb-xkb-dev libpam0g-dev

Manual Dependencies


Unfortunately, json-c isn't in the required version, even on Debian Buster. We need to compile it by hand:

$ git clone https://github.com/json-c/json-c.git
$ cd json-c
$ sh autogen.sh
$ ./configure --prefix=/usr/local
$ make
# make install


wlroot is a generic library for Wayland compositors. It has been developed focusing primarily Sway but it can also be used with other projects.

$ git clone https://github.com/swaywm/wlroots.git
$ cd wlroots
$ meson build
$ ninja -C build
# ninja -C build install

Sway building

Now it is time to build Sway.

$ git clone https://github.com/swaywm/sway.git
$ cd sway
$ meson build
$ ninja -C build
# ninja -C build install

Configuring Sway

You just need to copy your i3 configuration file into ~/.config/sway/config. Here is mine as an example with some adjustments for multiscreen and input configuration:

# Sway config file

# Keyboard configuration
input "5426:267:Razer_Razer_Arctosa" {
xkb_layout fr
xkb_variant latin9
xkb_model pC105
xkb_numlock enabled

# Dual screen configuration
output DP-1 pos 0 0 mode 1920x1080 background /usr/local/share/backgrounds/sway/Sway_Wallpaper_Blue_1920x1080.png center
output DVI-I-2 pos 1920 0 mode 1680x1050 background /usr/local/share/backgrounds/sway/Sway_Wallpaper_Blue_1366x768.png center

set $mod Mod4

# Set font for lower bar
font pango:DejaVu Sans Mono 10

# Use Mouse+$mod to drag floating windows to their wanted position
floating_modifier $mod

# Start a terminal. I use terminology, the enlightenment terminal.
# It does work natively under Wayland.
# See https://www.enlightenment.org/about-terminology
bindsym $mod+Return exec terminology -B

# Lock the screen
bindsym $mod+m exec swaylock

# kill focused window
bindsym $mod+Shift+Q kill

# start dmenu (a program launcher)
bindsym $mod+d exec dmenu_run

# change focus
bindsym $mod+j focus left
bindsym $mod+k focus down
bindsym $mod+i focus up
bindsym $mod+l focus right

# alternatively, you can use the cursor keys:
bindsym $mod+Left focus left
bindsym $mod+Down focus down
bindsym $mod+Up focus up
bindsym $mod+Right focus right

# move focused window
#bindsym $mod+Shift+J move left
#bindsym $mod+Shift+K move down
#bindsym $mod+Shift+L move up
#bindsym $mod+Shift+M move right

# alternatively, you can use the cursor keys:
bindsym $mod+Shift+Left move left
bindsym $mod+Shift+Down move down
bindsym $mod+Shift+Up move up
bindsym $mod+Shift+Right move right

# split in horizontal orientation
bindsym $mod+h split h

# split in vertical orientation
bindsym $mod+v split v

# enter fullscreen mode for the focused container
bindsym $mod+f fullscreen

# change container layout (stacked, tabbed, default)
bindsym $mod+s layout stacking
bindsym $mod+z layout tabbed
bindsym $mod+e layout default

# change screen
bindsym $mod+x move container to output DVI-I-2
bindsym $mod+w move container to output DP-1

# toggle tiling / floating
bindsym $mod+Shift+space floating toggle

# change focus between tiling / floating windows
bindsym $mod+space focus mode_toggle

# focus the parent container
bindsym $mod+q focus parent

# focus the child container
#bindcode $mod+d focus child

# workspaces definition
workspace 1: Mail output DVI-I-2
workspace 2: Web output DP-1
workspace 3: Terminal output DP-1
workspace 4: Emacs output DP-1
workspace 5: Music output DVI-I-2

# switch to workspace
bindsym $mod+ampersand workspace 1: Mail
bindsym $mod+eacute workspace 2: Web
bindsym $mod+quotedbl workspace 3: Terminal
bindsym $mod+apostrophe workspace 4: Emacs
bindsym $mod+parenleft workspace 5: Music
bindsym $mod+minus workspace 6
bindsym $mod+egrave workspace 7
bindsym $mod+underscore workspace 8
bindsym $mod+ccedilla workspace 9
bindsym $mod+agrave workspace 10

# move focused container to workspace
bindsym $mod+Shift+ampersand move workspace 1: Mail
bindsym $mod+Shift+eacute move workspace 2: Web
bindsym $mod+Shift+quotedbl move workspace 3: Terminal
bindsym $mod+Shift+apostrophe move workspace 4: Emacs
bindsym $mod+Shift+parenleft move workspace 5: Music
bindsym $mod+Shift+minus move workspace 6
bindsym $mod+Shift+egrave move workspace 7
bindsym $mod+Shift+underscore move workspace 8
bindsym $mod+Shift+ccedilla move workspace 9
bindsym $mod+Shift+agrave move workspace 10

# reload the configuration file
bindsym $mod+Shift+C reload
# restart sway inplace (preserves your layout/session, can be used to upgrade sway)
bindsym $mod+Shift+R restart
# exit sway (logs you out of your X session)
bindsym $mod+Shift+E exit

# resize window (you can also use the mouse for that)
mode "resize" {
# These bindings trigger as soon as you enter the resize mode
# They resize the border in the direction you pressed, e.g.
# when pressing left, the window is resized so that it has
# more space on its left

bindsym j resize shrink left 10 px or 10 ppt
bindsym Shift+J resize grow   left 10 px or 10 ppt

bindsym k resize shrink down 10 px or 10 ppt
bindsym Shift+K resize grow   down 10 px or 10 ppt

bindsym l resize shrink up 10 px or 10 ppt
bindsym Shift+L resize grow   up 10 px or 10 ppt

bindsym m resize shrink right 10 px or 10 ppt
bindsym Shift+M resize grow   right 10 px or 10 ppt

# same bindings, but for the arrow keys
bindsym Left resize shrink left 10 px or 10 ppt
bindsym Shift+Left resize grow   left 10 px or 10 ppt

bindsym Down resize shrink down 10 px or 10 ppt
bindsym Shift+Down resize grow   down 10 px or 10 ppt

bindsym Up resize shrink up 10 px or 10 ppt
bindsym Shift+Up resize grow   up 10 px or 10 ppt

bindsym Right resize shrink right 10 px or 10 ppt
bindsym Shift+Right resize grow   right 10 px or 10 ppt

# back to normal: Enter or Escape
bindsym Return mode "default"
bindsym Escape mode "default"
bindsym $mod+r mode "resize"

# lower bar configuration
bar {
status_command i3status
output DP-1

bar {
output DVI-I-2
status_command i3status

# assign workspaces
assign [title="mutt"] 1: Mail
assign [class="Firefox"] 2: Web
assign [title="Terminal" title="Terminal" app_id="terminology"] 3: Terminal
assign [title="Emacs"] 4: Emacs
assign [title="Cantata"] 5: Music

# Start my main tools when the session opens
exec terminology -B -T=mutt -n=Mutt -r=Mutt -e mutt
exec terminology -B -T=Terminal -n=Terminal -r=Terminal
exec terminology -B -T=Emacs -n=Emacs -r=Emacs -e emacs
exec cantata
exec firefox

Launch a sway session

Sway doesn't have a session manager. As Sway is a Wayland compositor it requires to be started whenever you start a session. For the moment, I have just modified my .bashrc configuration to start sway whenever I am login under tty1 and then configure the different graphical libraries (GTK/QT/EFL/etc.) to use Wayland instead of Xorg:

# Sway configuration
export LD_LIBRARY_PATH="/usr/local/lib"
# you can also configure your keyboard this way
#export XKB_DEFAULT_VARIANT=latin9
#export XKB_DEFAULT_MODEL=pc105
export QT_QPA_PLATFORM=wayland
export ELM_DISPLAY=wl
export ECORE_EVAS_ENGINE=wayland_shm

# Launch Sway when logging under tty1
if [ $(tty) = "/dev/tty1" ]; then
  exit 0

I have gotten rid of all the session managers on my system (no more slim nor gnome-session). I am prompted to log under the text mode console. OldSchoolCool!

What doesn't work very well?

Even if Sway is working very well on three of my computers there are still some problems around.

On some computers I have lots of glitches with firefox. This is my main problem for the moment. Firefox can only be compiled under Xorg, there is nothing official for Wayland. So it relies on XWayland and for some graphical cards, it seems to be a problem.

The second problem I faced is a keyboard one. On my laptop I could not use the traditional keys for moving a window towards a screen (mod+shift+number of the screen). I had to modify the configuration file to reflect the base (without shift pressed) character of the key (eg: aecute for 3 on a french keyboard).

I had also some problems with (proprietary) games that required a full Xorg session. But as long as I am able to play to Stardew Valley, it is not really important. Furthermore, I can log in tty2 and launch Xorg by hand (startx).

The last problem is probably the fact that I have to compile sway every week because it is not already available in Debian…

As long as you use Gnome softwares, you will enjoy the Wayland experience. Same thing for Qt5 (with the configuration above).


As a conclusion, Sway impressed me. It is a Wayland replacement for i3. There is nearly no new features. I am not lost nor do I need to learn something new. Furthermore it is coded in C, a language I really enjoy and which is able to build a complete tile window manager in a robust, compact and fast way. If you are an i3 enthousiast, you will enjoy Sway whenever you will migrate to Wayland.