a few months back i switched from i3 to sway. since this is a “wayland compositor” and not an X11 window manager, i needed to switch some tools around the wm as well.
here are some snippets on what i did to make everything working on archlinux and manjaro.
installation
just install sway
, along with swayidle
and swaylock
(to lock the screen on inactivity), and xorg-xserver-wayland
to run X11 applications on wayland.
sudo pacman -S sway swayidle swaylock xorg-xserver-wayland
configuration
-> sway wiki
the config file is located at ~/.config/sway/config
.
if you dont have that, you can copy a default config from /etc/sway/config
.
adapt the following things to your needs, and add them to your sway config!
keyboard layout
input * xkb_layout "de"
swayidle / swaylock
use swayidle to run a command on inactivity.
i turn off all outputs after 300s of inactivity, and lock the screen after 600s and “before sleep”.
exec swayidle -w \
timeout 600 'swaylock -f -c 000000' \
timeout 300 'swaymsg "output * dpms off"' \
resume 'swaymsg "output * dpms on"' \
before-sleep 'swaylock -f -c 000000'
also, i bind mod+escape to swaylock to lock manually. (-f
daemonizes, -c 000000
sets a black screen)
bindsym $mod+Escape exec swaylock -f -c 000000
displays
if you dont switch screens a lot, its probably fine to just define your config in your sway config file. just get the available modes from swaymsg -t get_outputs
, and set something like
output HDMI1 pos 0 0 res 1920x1080
output eDP1 pos 1920 0 res 1600x900
instead of the port (HDMI1
, eDP1
) you can also use the name found in get_outputs
!
the coordinates (pos 0 0
) are starting in the upper left and grow right and downwards. the result will look something like this.
x y
0 0 1920 0
+------------------+---------------+
| | |
| | |
| | |
| | |
| +---------------+
| |
+------------------+
if you want to scale your screens, you can do so by setting output HDMI1 scale 2
. in this case, the x-coordinate of the second screen is 1920*2
, 3840!
the sway wiki does not recommend fractional scaling, but i never had issues with this and i like to run my hidpi screens on a scale around 1.6
.
kanshi
if you switch your displays often, eg. you connect your laptop to different screens with different setups, kanshi (arch user repo) is a nice tool to handle the configuration.
the idea is that you describe your different display setups, and when all displays in a setup are connected, the config will be applied.
to start, create a new config file in .config/kanshi/config
.
the syntax is a bit different from the sway config syntax.
{
output eDP-1 enable scale 1.6 mode 2560x1440 position 0,0
}
{
output eDP-1 enable scale 1.6 mode 2560x1440 position 0,0
output "Some Display 0x0123" enable scale 2 mode 3840x2160 position 1600,0
}
{
output eDP-1 enable scale 1.6 mode 2560x1440 position 0,0
output "Another Display" enable scale 1.3 mode 2560x1440 position 1600,0
}
after you saved your config, try by starting kanshi: kanshi
.
if everything works as you expect, add exec kanshi &
to your sway config to run kanshi when you start sway!
brightness
to control screen brightness i decided to use brightnessctl
. (i used light before, but brightnessctl
is in the arch repos.)
just run sudo pacman -S brightnessctl
to install, and add your user to the video
group with sudo usermod -aG video USERNAME
. otherwise, you wont be allowed to change brightness.
in sway config, add
bindsym XF86MonBrightnessUp exec --no-startup-id brightnessctl set 10%+
bindsym XF86MonBrightnessDown exec --no-startup-id brightnessctl set 10%-
to bind the keys to the brightnessctl
commands.
hiding cursors on inactivity
i like to not see the curser when i dont use it. just add this to the sway config.
seat * hide_cursor 8000
other replacements
dmenu -> bemenu
since dmenu
is x11, you could switch to bemenu
. it feels the same, but is wayland.
sudo pacman -S bemenu
in sway config:
set $bemenu_options -i --nb "#3f3f3f" --nf "#dcdccc" --fn "pango:DejaVu Sans Mono 12"
set $menu_command bemenu $bemenu_options
set $menu dmenu_path | $menu_command | xargs swaymsg exec
screenshots
for screenshots, i use a combination of grim and slurp.
slurp
lets you select a region on screen and prints the coordinates, which you can use as input for grim
, which then creates the actual screenshot.
in the end, i pipe the output to wl-copy
(which is part of wl-clipboard
), to paste it wherever i need it.
sudo pacman -S grim slurp wl-clipboard
sway config:
bindsym $mod+Print exec grim -g "$(slurp)" - | wl-copy
notifications
mako is a notification daemon.
sudo pacman -S mako
sway config:
exec mako --default-timeout 5000 &
redshift
if you used redshift before, you will notice that it doesnt work. there is an aur for a patched version: redshift-wayland-git
NetworkManager Applet
unfortunately the nm-applet is not showing on wayland. i just started to use “NetworkManager text user interface”, nmtui
, instead.
not really sway-related, but tricky on wayland
fixing intellij
intellij starts with a blank window. the problem (and the solution) is described here
short version: fix it by adding _JAVA_AWT_WM_NONREPARENTING=1
to /etc/environment.
finding out which application is X or wayland
if you want to find out which applications are running on wayland, you can just start xeyes. the eyes only follow the cursor on X applications. :)
sudo pacman -S xorg-xeyes
running firefox on wayland
normally firefox is an X application, but you can set
MOZ_ENABLE_WAYLAND=1
and it will use wayland. just throw it in your /etc/environment, same as the intellij fix!