swaywm/swayidle

swayidle resumes immediately with SIGUSR1

MichaelAquilina opened this issue · 7 comments

  • Sway Version: 1.1

Running swayidle and then sending it a SIGUSR1 signal enters an idle state as expected - but it then immediately enters the active state again without any interaction.

This is quite easy to reproduce by running this command:

swayidle -w -d \
    timeout 300 'swaymsg "output * dpms off"' \
    resume 'swaymsg "output * dpms on"' 

and then in a separate shell running this command:

killall -SIGUSR1 swayidle

This will cause the screen to turn off but then immediately turn back on (the only delay being the actual time the screen takes to turn back on).

I would expect that given these set of commands that the state would remain as "idle" and the screen would remain off.

Here is the output of the sway idle command on my terminal:

Got timeout
Register idle timeout at 300000 ms
Setup idle
Command: swaymsg "output * dpms off"
Setup resume
Command: swaymsg "output * dpms on"
Register with timeout: 300000
Got SIGUSR1
Register with timeout: 0
idle state
Cmd exec swaymsg "output * dpms off"
Spawned process swaymsg "output * dpms off"
active state
Register with timeout: 300000
Cmd exec swaymsg "output * dpms on"
Spawned process swaymsg "output * dpms on"
Got SIGUSR1
Register with timeout: 0
idle state
Cmd exec swaymsg "output * dpms off"
Spawned process swaymsg "output * dpms off"
active state
Register with timeout: 300000
Cmd exec swaymsg "output * dpms on"
Spawned process swaymsg "output * dpms on"

I have a similar setup, and I can't reproduce.

Tried this on the latest master just in case and stil seem to get the same issue.

Interesting that you dont see the same problem @emersion - I wonder if its something to do with my configuration.

For the record, dpms turns off and stays off when I wait for an actual idle timeout to occur (ie not sending a SIGUSR1)

Possibly wakes up when the enter key releases, have you tried a slower command e.g. sleep 1; killall -SIGUSR1 swayidle ?

@martinetd sleep 1; killall -SIGUSR1 swayidle does indeed work as expected. Is there any way we could cater for this within swayidle? I had a look a the code last night but nothing obvious stood out to me.

No, there's no way to include this in swayidle. You can bindsym --release instead, or keep the sleep.

bindsym --release does not seem to work. However the workaround sleep 0.1 && killall -SIGUSR1 swayidle seems to be reasonable.

I guess bindsym --release does not work for you because you're using a key combination like $mod+<some_key> and --release acts when you release <some_key> but then it immediately turns back on your screen because you release the $mod. Does it make sense?