Open tchebb opened 3 years ago
Sorry for the late response.
I'm not opposed to this. However, I think there should be a configurable timeout; someone may want their screen to stay on for some time after locking before the display powers off. That's approximately how my setup currently works, where swayidle locks the screen after some period of inactivity, then turns off the screen 20 seconds after that.
I'm aware that this will significantly complicate the logic though. Nonetheless, I think it's important.
@mortie I'm using the same staged approach where I first lock the screen after an initial delay and only after a delay turn off the screen. For that usecase, swayidle is already covering configuring delays.
I still see this PR useful for usecases where you want to lock instantly (e.g. by a keyboard shortcut). Please reconsider if this could be accepted.
(Originally submitted upstream as swaywm/swaylock#152, but rejected as out-of-scope.)
This option makes use of the new wlr-output-power-management protocol to power off displays when swaylock is idle (i.e. when the unlock indicator, if enabled, is not shown).
This approach provides far more reliable DPMS control than the currently recommended solution, which is to use something above swaylock (e.g. swayidle) to coordinate swaylock invocation with a separate swaymsg invocation to control DPMS. Since swayidle is purely input-based and cannot inspect swaylock's state, it will inevitably either power up the screens when it shouldn't or fail to when it should. For example, if swayidle is set to turn on the screens on "resume," it will do so even if the only input was a mouse bump, modifier key press, or something else that swaylock ignores completely.
This is a first pass at the functionality. I've been using it on my laptop with Sway for several months and it seem to work well. However, I occasionally do get in a state where the screen is stuck off after resuming, which I assume means the power manager interface has gone away. I have not yet tracked down why this happens.