swaywm / swayidle

Idle management daemon for Wayland
MIT License
554 stars 50 forks source link

swayidle crashes screenlockers after suspend #146

Closed proudhon closed 1 year ago

proudhon commented 1 year ago

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

emersion commented 1 year ago

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

proudhon commented 1 year ago

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