swaywm / swayidle

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

Swayidle stops working at random with external monitor #141

Closed pielgrzym closed 1 year ago

pielgrzym commented 1 year ago

Hi,

I have a latop with usb-c attached secondary monitor. I run swayidle like this:

swayidle -w timeout 600 'swaylock' timeout 1200 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"' before-sleep 'swaylock'

I lock the screen with a sway keybind for killall -USR1 swayidle and most of the time it works just fine. However at random it starts behaving in weird way:

When it stops working at all restarting swayidle does not help - I need to disconnect the monitor to make it w ork again.

kennylevinsen commented 1 year ago

swayidle is working just fine here, the problem is that the command called - swaymsg - is not giving the result you want.

Open an issue towards sway. This might be driver issue, so look in dmesg as well.

pielgrzym commented 1 year ago

Thanks for rapid response. I thought of that and tried running the commands without swayidle to test if they work - both dpms shutdown and swaylock work, only not through swayidle. I'll investigate dmesg haven't thought of that :)

pielgrzym commented 1 year ago

@kennylevinsen no dmesg errors at all and DPMS is working fine. I also did another test to ensure it's purely swayidle. Instead of calling swaylock directly I called my test script, so the swayidle command looks like this:

swayidle -w -d timeout 600 '/tmp/test.zsh' timeout 1200 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"' before-sleep '/tmp/test.zsh'

The test.zsh contains only:

#!/bin/zsh

date >> /tmp/test.log
swaylock -d 2>&1 >> /tmp/test.log

As you can see I tried capturing swaylock output, but for some reason even if swaylock works fine it's output is caught by swayidle not in the log.

After a few hours my issue happens - sending SIGUSR1 to swayidle does not run swaylock. And the test.zsh script is not being ran at all.

Is it possible that swayidle is running the dpms command first, the command fails for some reason and it blocks execution of further commands? If this is the case it must be intermittent, since I can immediately run the command in my shell and screen promptly shuts down.

pielgrzym commented 1 year ago

Oh, yeah - and I can run swaymsg 'output * dpms off' && sleep 3 && swaymsg 'output * dpms on' - it shuts down and enables dpms without a problem, but swayidle does not do this.

pielgrzym commented 1 year ago

I looked into source code - so basically I get two "Register with timeout: 0" debug messages, this means both commands should be triggered, but they are not for some reason.

pielgrzym commented 1 year ago

Sooo this might not be related to swayidle afterall ;) It appears that the locking occurs - it's just super-late. I sent SIGUSR1 several times and went on to read source code for swayidle and after 10 minutes my dpms+swaylock kicked in. So there indeed is almost no logic is there to fail, so the issue must be with ext-idle-notify.

pielgrzym commented 1 year ago

Ah, ok - I see now - I'll investigate this further and report in sway repo. Sorry! :)))