sway: swayidle does not light up a screen upon pressing a key
Per this comment, the preferred way of lighting up the screen from dpms is through swayidle. Unfortunately, for me the screen remains dark even with swayidle running in background.
Steps to reproduce
- Execute in one terminal
swayidle timeout 600 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"' - Execute in another terminal
sleep 1 && swaymsg "output * dpms off" - Press a key
Expected
Screens light up back
Actual
Screens stay black, and I see no way to light them up.
Additional info
sway build from today, commit a4d68358.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 25 (22 by maintainers)
I was just stumbling upon the same thing, my usecase is: I want to turn off the display immediately on demand (for example after a movie finishes), by script. A solution that would work for me would be, if swayidle itself hat a oneshot/once option, i.e. run:
swayidle --once timeout 1 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"'After that, swayidle exits only when the display comes back on.
If you need pseudo code, here:
killall -USR1 swayidleOr as oneshot:
Err? Why would it not need a resume command? If you don’t need a resume command, you don’t need swayidle, just run the damn initial command.
I’ll repeat myself one last time: you need something to ask the compositor to tell you when there is activity. idle as it is has two stages: it starts active, then if there is no activity until timer hits notifies the client once (idle command) and enters idle state. In idle state, it will notify the first activity to the client and exit idle state, waiting for timer again.
Basically what you need here is to add a new more/handle an event/whatever that would let you first execute a command and immediately enter idle state, to be able to wake up screens on first activity, then destroy that thing.
a 0-timer would be just that: create timer, (run your thing now or run it on the immediate idle event), run resume command when it comes, kill timer.
I do not care what kind of API you give to that, you can execute the same command for all resume events or you can do them individually (it’d make more sense to do them individually if you only want to shutdown a single screen one-shot e.g. for video playback on one screen with multiscreen, but that’s not my problem), but this doesn’t need anything new. It’s a pure user/client program, and that doesn’t need anything more from the compositor, just do it and send a PR.
(TLDR: I’m sorry if you think that’s rude, I’m just tired of repeating what I consider to be the same thing over and over; I won’t reply to this issue anymore.)
The problem is that swayidle wouldn’t even get a resume event in that case, because the compositor only sends it if it considers it was idle when activity happens (can’t really go around and notify every listener everytime something moves)
We need to add a way to tell the compositor “from here on notify me the next time something happens” or something similar; I don’t think there’s any way to do that with the current protocols. Maybe just set a 0s idle timeout? Have you tried something like this (can improve the pkill if it works)?
swayidle timeout 0 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"; pkill -n swayidle'?