swaywm/swayidle

Recommended way to combine with manual locking

NickeZ opened this issue · 2 comments

Hi, I've been trying to create a config were swaylock will be launched both on idle and on a keyboard shortcut. This is my current attempt:

exec swayidle -w \
         timeout 10 'if pgrep swaylock; then swaymsg "output * dpms off"; fi' \
         timeout 60 'if ! pgrep swaylock; then swaylock -f -c 000000; fi' \
         timeout 90 'swaymsg "output * dpms off"' \
              resume 'swaymsg "output * dpms on"' \
         before-sleep 'if ! pgrep swaylock; then swaylock -f -c 000000; fi'
bindsym --release $mod+Shift+s exec "swaylock -c 000000"

With this config I run into the problem that the screen continues to be off even after I unlock the machine.

I'm using systemd so I guess a combination of lock / unlock / timeout / resume + binding some dbus-send on keyboard shortcut could also do the trick?

Thanks

Try:

exec swayidle -w \
         timeout 60 'swaylock -f -c 000000' \
         timeout 90 'swaymsg "output * dpms off"' \
              resume 'swaymsg "output * dpms on"' \
         before-sleep 'swaylock -f -c 000000' \
         lock 'swaylock -f -c 000000'
bindsym --release $mod+Shift+s exec loginctl lock-session

or killall -USR1 swayidle