sway/config: Launch swayidle and kanshi from systemd

Launch swayidle and kanshi from systemd user session instead of via
sway's config. This way they bind to the sway-session target and s-
tart/stop automatically when sway is started/stopped. As a bonus,
they don't get launched again when you reload sway.

See: https://github.com/swaywm/sway/wiki/Systemd-integration
This commit is contained in:
Alan Orth 2021-09-30 18:57:16 +03:00
parent 765160ae5e
commit 15dafd4bca
Signed by: alanorth
GPG Key ID: 0FB860CC9C45B1B9

View File

@ -51,9 +51,6 @@ output * bg /usr/share/backgrounds/sway/Sway_Wallpaper_Blue_1920x1080.png fill
#
# You can get the names of your outputs by running: swaymsg -t get_outputs
# Manage outputs with kanshi
exec_always pkill kanshi; exec kanshi
# Wayland overlay bar for sound and brightness level
exec mkfifo $SWAYSOCK.wob && tail -f $SWAYSOCK.wob | wob
@ -61,13 +58,10 @@ exec mkfifo $SWAYSOCK.wob && tail -f $SWAYSOCK.wob | wob
#
# Example configuration:
#
set $lock_bg ~/Downloads/3121px-Jerusalem-2013-Temple_Mount-Dome_of_the_Rock-Detail_01.jpg
exec swayidle \
timeout 300 'swaylock -c 000000 -i $lock_bg' \
timeout 600 'swaymsg "output * dpms off"' \
resume 'swaymsg "output * dpms on"' \
before-sleep 'swaylock -c 000000 -i $lock_bg'
# exec swayidle -w \
# timeout 300 'swaylock -f -c 000000' \
# timeout 600 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"' \
# before-sleep 'swaylock -f -c 000000'
#
# This will lock your screen after 300 seconds of inactivity, then turn off
# your displays after another 300 seconds, and turn your screens back on when
@ -275,3 +269,6 @@ bar {
}
include /etc/sway/config.d/*
# Start sway-session.target, to which kanshi.service and swayidle.service bind.
exec_always "systemctl --user import-environment; systemctl --user start sway-session.target"