Home > Articles > Trying Wayland and Sway

Trying Wayland and Sway - Robin Wils's website

Last modified: Sat, Dec 28, 2019

Table of Contents

Why move to Wayland?

Wayland is supposed to be more secure than Xorg. There are some other valid reasons to use it. I moved to it because Xorg broke, and I stayed because it works.

Which options are there?

GNOME and KDE support Wayland. There are some window managers which support Wayland. I use Sway, which is like i3.

You can find some more options on the Arch wiki.

What you should know before moving

Things which won't work

VirtualBox and VMware don't support Wayland yet. There is a fix for VirtualBox which can be found on the Arch wiki.

I moved to QEMU. QEMU is a bit harder to setup, but it can be worth it.

GUI Libraries

GUI Libraries might need some configuration.


Many applications use GTK. GTK supports Wayland by default. GTK has a dark theme if you prefer dark themes.

Add the following to your ~/.bash_profile (or .zsh_profile if you use zsh) to use the dark theme.

export GTK_THEME=Adwaita:dark


Many applications use QT, but QT needs a few things before it works on Wayland. You have to install the qt5-wayland package for Wayland support.

Add the following snippet to your ~/.bash_profile (or .zsh_profile if you use zsh) to set the right environment variables for QT.

It is possible to give QT apps a GTK theme by installing qt5ct. Launch qt5ct and change the Standard dialogs dropdown to GTK.

# Enable QT apps to have a GTK theme
# Force Wayland on QT apps
export QT_QPA_PLATFORM=wayland

Java applications

The following snippet is needed on some window managers like Sway. Java applications won't display correctly without that snippet.

# Make Java apps display correctly on wms

Multiple displays

Some tools which are made for Xorg won't work on Wayland, arandr and xrandr are made for Xorg.


wdisplays is a GUI to configure the display configuration. You can find it in the AUR if you use Arch. I am not sure of it exists in the repositories of other distros.


kanshi is a tool which automatically sets your display configuration when you connect or disconnect a display. It works like autorandr. You can find it in the community repository on Arch.

A example of ~/.config/kanshi/config could look like this:

# When the displays eDP-1 and DP-4 are connected.
	# Left display (look at position, wdisplays can make this easier)
	output eDP-1 mode 1920x1080@60.052Hz position 0,0 scale 1
	# Right display
	output DP-4 mode 1920x1080@60Hz position 1920,0 scale 1
# When only the display eDP-1 is connected.
	output eDP-1 mode 1920x1080@60.052Hz position 0,0 scale 1

You will have to run the kanshi command to run it.

Taking screenshots

You will need grim and slurp to take screenshots. I also recommend wl-clipboard, so that you can copy the screenshot to your clipboard.

# Take a screenshot, save it and copy it to your clipboard
grim -g "$(slurp)" ~/screen.png | wl-copy

Other things

Most other things should just work. You can run X applications in Wayland. You should look into the keyboard configuration. It is different depending on which desktop environment or window manager you pick.


I use Sway and decided to place a configuration for it here. Sway claims that your current i3 configuration should work. It works, but not completely.

Small note

Before you look at it. I use Dvorak the keys ‘.', ‘o’, ‘e’, ‘u’ are like ‘w’, ‘a’, ‘s’, ‘d’ on QWERTY.

The keys ‘h’, ‘t’, ‘c’, ‘n’ are also positioned like arrow keys on the right side of the keyboard.


I use bemenu to launch applications, which is not installed by default.

Jumpapp is another cool tool which switches to a window if it is open and opens it if it is not open yet. It is not installed by default.

i3status is the statusbar which I use. That is why I still have i3 installed. I also posted its config here.


# modkey
set $mod Mod4

# font
font pango:hack 9

# Focus no follow mouse
focus_follows_mouse no

# Default workspace layout, Sway does tiling by default
workspace_layout tabbed

# Set terminal emulator
set $term kitty

# Set menu, bemenu is dmenu for Wayland
set $menu bemenu-run -b --tf='#00ff70' --nf='#999999' --hf='#000000' --hb='#00ff70' --fn='pango:hack 12' -p ''

# Window colors
client.focused_inactive #0d1010 #0d1010 #AAAAAA #0d1010 #0d1010
client.unfocused #0d1010 #0d1010 #888888 #0d1010 #0d1010
client.focused #0d1010 #000000 #DDDDDD #0d1010 #0d1010

# Set workspaces
set $ws1 "1"
set $ws2 "2"
set $ws3 "3"
set $ws3 "4"

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

# Force floating on some windows
for_window [title="Android Emulator - Pixel_API_29:5554"] floating enable

# Set the keyboard layout to Dvorak
# Make Caps Lock to do Ctrl
input * {
		xkb_layout us
		xkb_variant dvorak
		xkb_options ctrl:nocaps

# Make the Shift keys do shift lock instead of shift
exec xmodmap -e "keycode 50 = Shift_Lock"
exec xmodmap -e "keycode 62 = Shift_Lock"

# Set wallpaper
output "*" bg /home/rmw/Pictures/Wallpapers/ryako-nerdcore-header.png center

# Only turn laptop screen on when lid not closed
set $laptopScreen eDP-1
bindswitch --reload lid:on output $laptopScreen disable
bindswitch --reload lid:off output $laptopScreen enable

exec kanshi # Automatically set display configuration
exec lxqt-policykit-agent # policykit-agent
exec emacs --daemon # Emacs daemon
exec mpd /home/rmw/.config/mpd/mpd.conf # Music Player Daemon

# Start keepassxc on workspace 1
exec swaymsg 'workspace 1; exec keepassxc'

# I no longer use a tray
# exec stalonetray --parent-bg true --sticky --icon-size=16 --window-layer top

# Switch to workspace
bindsym $mod+1 workspace number $ws1
bindsym $mod+2 workspace number $ws2
bindsym $mod+3 workspace number $ws3
bindsym $mod+4 workspace number $ws4

# Use pactl to adjust volume in PulseAudio.
bindsym XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +5%
bindsym XF86AudioLowerVolume exec pactl set-sink-volume @DEFAULT_SINK@ -5%
bindsym XF86AudioMute exec pactl set-sink-mute @DEFAULT_SINK@ toggle
bindsym XF86AudioMicMute exec pactl set-source-mute @DEFAULT_SOURCE@ toggle
bindsym XF86MonBrightnessDown exec brightnessctl set 5%-
bindsym XF86MonBrightnessUp exec brightnessctl set +5%
bindsym XF86AudioPlay exec playerctl play-pause
bindsym XF86AudioNext exec playerctl next
bindsym XF86AudioPrev exec playerctl previous

# Kill focused window
bindsym $mod+q kill
# Reload the configuration file
bindsym $mod+c reload
# Exit Sway (logs you out of your Wayland session)
bindsym $mod+Escape exec swaynag -t warning -m 'You pressed the exit shortcut. Do you really want to exit sway? This will end your Wayland session.' -b 'Yes, exit sway' 'swaymsg exit'

# Split in horizontal orientation
bindsym $mod+h split h
# Enter fullscreen mode for the focused container
bindsym $mod+f fullscreen toggle
# Toggle tiling / floating
bindsym $mod+Shift+space floating toggle
# Change focus between tiling / floating windows
bindsym $mod+space focus mode_toggle
# Screenshot key
bindsym Print exec grim -g "$(slurp)" /home/rmw/screen.png | wl-copy

# MPD mode
mode "mpd-mode" {
		bindsym space exec mpc toggle
		# change focus
		bindsym o exec mpc prev
		bindsym e exec mpc volume -5
		bindsym period exec mpc volume +5
		bindsym u exec mpc next

		bindsym s exec mpc shuffle
		bindsym l exec mpc repeat
		bindsym r exec mpc random

		# back to normal mode
		bindsym $mod+q mode "default"
		bindsym Escape mode "default"

bindsym $mod+p mode "mpd-mode"

# Window focus mode
mode "window-focus" {
		# change focus
		bindsym o focus left
		bindsym e focus down
		bindsym period focus up
		bindsym u focus right

		# move focused window
		bindsym h move left
		bindsym t move down
		bindsym c move up
		bindsym n move right

		# back to normal mode
		bindsym $mod+q mode "default"
		bindsym Escape mode "default"

bindsym $mod+w mode "window-focus"

# Move to workspace mode
mode "move-to-workspace" {
		# move focused container to workspace
		bindsym 1 move container to workspace number $ws1
		bindsym 2 move container to workspace number $ws2
		bindsym 3 move container to workspace number $ws3
		bindsym 4 move container to workspace number $ws4

		# move workspace
		bindsym o move workspace to output left
		bindsym e move workspace to output down
		bindsym period move workspace to output up
		bindsym u move workspace to output right

		# back to normal mode
		bindsym $mod+q mode "default"
		bindsym Escape mode "default"

bindsym $mod+m mode "move-to-workspace"

# Resize mode
mode "resize" {
		# resize windows
		bindsym o resize shrink width 10 px or 10 ppt
		bindsym e resize grow height 10 px or 10 ppt
		bindsym period resize shrink height 10 px or 10 ppt
		bindsym u resize grow width 10 px or 10 ppt

		# back to normal mode
		bindsym $mod+q mode "default"
		bindsym Escape mode "default"

bindsym $mod+r mode "resize"

# Launch applications mode
mode "launch-applications" {
		# start bemenu (a program launcher)
		bindsym $mod+d exec $menu, mode "default"

		# jumpapp
		bindsym t exec jumpapp $term
		bindsym a exec jumpapp android-studio
		bindsym b exec jumpapp abrowser
		bindsym d exec jumpapp wdisplays
		bindsym k exec jumpapp keepassxc
		bindsym w exec jumpapp wicd-client
		bindsym e exec jumpapp emacs

		# back to normal mode
		bindsym $mod+q mode "default"
		bindsym Escape mode "default"

bindsym $mod+l mode "launch-applications"

bar {
		tray_output primary
		font pango:hack 9
		status_command i3status
		position top
		workspace_buttons no
		separator_symbol " "


general {
		colors = true
		interval = 5

order += "volume master"
order += "wireless _first_"
order += "ethernet _first_"
order += "battery all"
order += "tztime local"

wireless _first_ {
		format_up = "W: %quality"
		format_down = "W: down"

ethernet _first_ {
		format_up = "E: %speed"
		format_down = "E: down"

battery all {
		format = "%status: %percentage"

tztime local {
		format = "%Y-%m-%d %H:%M "

volume master {
		format = "V: %volume"
		format_muted = "V: muted %volume"
		device = "default"
		mixer = "Master"
		mixer_idx = 0

Home > Articles > Trying Wayland and Sway