Photo by Marvin Meyer / Unsplash

Sway - The small nifty tweaks part 1

Linux May 27, 2022

Sometimes it's the small things that will greatly improve your window managers behavior.

Consistent Displays

I noticed that my current laptop did not correctly set up my monitors when my laptop lid was closed. The internal display port was always enabled after config reload.

Now after some research I know there is a --reload flag for bindswitch.

So the correct setup for your monitor setup should be something like this:

# You can get the names of your outputs by running: swaymsg -t get_outputs
output "Samsung Electric Company C49RG9x H1AK500000" resolution 5120x1440 position 1920,0
output eDP-1 resolution 3840x2160 position 0,0

# Watch closed laptop lid
set $laptop eDP-1
bindswitch --reload --locked lid:on output $laptop disable
bindswitch --reload --locked lid:off output $laptop enable

# Display timeouts
exec_always swayidle -w \
      timeout 150 'swaylock-blur -- -f' \
      timeout 300 'swaymsg "output * dpms off"' \
      		resume 'swaymsg "output * dpms on"' \
      		before-sleep 'swaylock-blur -- -f'

This will ensure that your displays are correctly positioned (1920 offset to the 4k monitor because it's scaled 2x) and reload correctly when you refresh your configuration.

Also disable Kanshi if you use a setup with only one large monitor in addition to the internal laptop display. This also fixes some unwanted behavior while reloading your config.

Tags