swaywm/swayidle

swayidle crashes screenlockers after suspend

proudhon opened this issue · 2 comments

This occurs with gtklock swaylock swaylock-effects.

this is my swayidle script:

#!/bin/bash
swayidle -w \
	timeout 30 '/home/[REDACTED]/gtklock/gtklock.sh' \
	timeout 40 'hyprctl dispatch dpms off' \
	resume 'hyprctl dispatch dpms on' \
        timeout 50 'systemctl suspend' \
	before-sleep '/home/[REDACTED]/gtklock/gtklock.sh' 

My first approach was to create a script that would pgrep for an existing instance of the screenlocker and start it only if there isn't one - e.g. gtklock.sh:

#!/bin/bash
if pgrep -x "gtklock" >/dev/null; then
	echo "dummy" >/dev/null
else
	gtklock -d
fi

I then thought this approach would cause the crash and proceeded to simply launching the daemonized screenlockers:

#!/bin/bash
swayidle -w \
	timeout 30 'gtklock -d' \
	timeout 40 'hyprctl dispatch dpms off' \
	resume 'hyprctl dispatch dpms on' \
        timeout 50 'systemctl suspend' \
	before-sleep 'gtklock -d' 

Both approaches result in a crash waking up from suspend.

gtklock -d; systemctl suspend and swaylock -f; systemctl suspend do not result in any crash.

I'm on Arch Linux and using Hyprland as wm.

Edit: wrongfully pasted two lines in the scripts

If the screen locker crashes, it's a screen locker bug, not a swayidle bug.

I can't understand the logic behind this but solved it by calling systemctl suspend indirectly in a separate bash script.