swaywm/swayidle

FR: second timeout for DPMS when locked screen + idle

camoz opened this issue · 9 comments

camoz commented

Hi all,

In the default sway config swayidle is started like so:
exec swayidle timeout 300 'swaylock -c 000000' timeout 600 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"' before-sleep 'swaylock -c 000000'

...which means, after 600 seconds the screen is locked and powered down. If I then move my mouse, screens are powered on and the lockscreen is shown. However, if I've moved my mouse only by accident, I have to wait the full DPMS timout before my screens are powered off again, right?

I thought it would be nice to have a second timeout for when that happens (maybe timeout --locked), so that I can say "please turn my screen off again if I don't start entering my password after 10 sec".

This feature is NOT really important to me, I more want to record this thought here, as it may be a useful feature.

Thanks for reading.

I'm not sure we want to introduce more complexity in swayidle. Also, there's no good way for swayidle to detect if a lockscreen is running. I'd add another timeout that starts a script that detects if swaylock is running.

I thought about creating a dedicated session daemon that handles systemd and sway events for suspend, lid switch, screen lock, DPMS, logind idle flag and inhibiting those. I never got around to it since swayidle is currently good enough for me.

I thought about creating a dedicated session daemon that handles systemd and sway events for suspend, lid switch, screen lock, DPMS, logind idle flag and inhibiting those.

That would be neat.

@progandy I use an upstart fork to manage my login sessions.

I integrate logind, swayidle, swaylock, and brillo.

trbjo commented

It is not necessary with new code. Swayidle can already do that.

From my config:

timeout 10 'if pgrep swaylock; then swaymsg "output * dpms off"; fi'\
resume 'swaymsg "output * dpms on"'\

This works really well, but for some reason this also causes my screen (or wallpaper by the looks of it) to flash momentarily, if the timeout of 10 seconds has passed, but the screen is not locked (and swaylock is not active).
Edit: To clarify - the screen flashes only i the timer is reset, so if i do nothing for 10 seconds (as in your example configuration) and then press a key, my wallpaper will flicker.

@Gigg1ty that sounds like swaywm/sway#3892

I use the following workaround to resolve this:

First, lock the screen at 300 seconds.
Next, turn off the screen at 330 seconds.
If there is keyboard/mouse movement, turn the screen back on.
If 'swaylock' is running, lock the screen at 30 seconds.
If there is mouse/kebyoard movement, and 'swaylock' is running, turn the screen back on.

This seems to resolve all of the issues listed here, including the screen flicker on swaymsg "output * dpms on" being run when the display is already active.

exec swayidle -w \
    timeout 300 $locker \
    timeout 330 'swaymsg "output * dpms off"' \
    resume 'swaymsg "output * dpms on"' \
    timeout 30 'if pgrep swaylock; then swaymsg "output * dpms off"; fi' \
    resume 'if pgrep swaylock; then swaymsg "output * dpms on"; fi' \
    before-sleep $locker

Not only is swaybg restarted, but I get a pretty big lag spike (6 or 7 frames dropped) when output * dpms on is ran, despite being already on.