Closed CaptainBloodz closed 1 year ago
Can you post debug logs of swayidle
?
I don't know how to debug swayidle. Anyhow here's the original /sway/config snippet:
exec swayidle timeout 3600 '~/apps/grim/grim-master/build/grim /tmp/screen_locked.png && convert /tmp/screen_locked.png -scale 5% -scale 2000% /tmp/screen_locked.png && swaylock -f -i /tmp/screen_locked.png' timeout 60 'swaymsg "output dpms off"' resume 'swaymsg "output dpms on"'
Because 3600 is quite a long time to wait, I retested with shorter delays such as 8s/16s which works fine.
Currently I've reverted to initial 3600s/60s. Before the end of the day I will surely encounter a one hour hands-off situation to check if issue was more of a possible typo or durattion related, e.g. 3600.
Thks 4 ur attention, interest & support.
switching to "exec swayidle timeout 1000..." works fine, same command line length.
i have the same issue that multiple timeouts are not working. he timeout 300
, resume
and the before-sleep
are working. The commandline im starting swayidle
with is this one:
/usr/bin/swayidle -dw \
timeout 300 'swaylock -fe -i /usr/share/backgrounds/.bgimg.jpg' \
timeout 600 'swaymsg "output * dpms off"' \
resume 'swaymsg "output * dpms on"' \
before-sleep 'swaylock -fe -i /usr/share/backgrounds/.bgimg.jpg' \
and here is the debug output of the startup, will see if i can get the debug output for the timeout today:
Register with timeout: 300000
Register with timeout: 600000
Got sleep lock: 11
Failed to find session name: PID 918148 does not belong to any known session
Setup sleep lock: swaylock -fe -i /usr/share/backgrounds/.bgimg.jpg
Command: swaylock -fe -i /usr/share/backgrounds/.bgimg.jpg
Got before-sleep
Command: swaymsg "output * dpms on"
Setup resume
Command: swaymsg "output * dpms off"
Setup idle
Register idle timeout at 600000 ms
Got timeout
Command: swaylock -fe -i /usr/share/backgrounds/.bgimg.jpg
Setup idle
Register idle timeout at 300000 ms
Got timeout
debug log when trying to enter the second timeout:
idle state
Cmd exec swaymsg "output * dpms off"
Spawned process swaymsg "output * dpms off"
00:00:00.022 [swaymsg/main.c:417] Unable to retrieve socket path
Thanks for reporting this. As a temporary workaround, you can run multiple swayidle processes, each with its own timeout and resume. For example:
# Dim the screen after 5m of idle.
exec swayidle -w timeout 300 'brightnessctl set 15%-' \
resume 'brightnessctl set +15%'
# Turn off the display after 5m 10s of idle.
exec swayidle -w timeout 310 'swaymsg "output * dpms off"' \
resume 'swaymsg "output * dpms on"'
Not ideal, but it seems to work for now.
Thanks for reporting this. As a temporary workaround, you can run multiple swayidle processes, each with its own timeout and resume. For example:
# Dim the screen after 5m of idle. exec swayidle -w timeout 300 'brightnessctl set 15%-' \ resume 'brightnessctl set +15%' # Turn off the display after 5m 10s of idle. exec swayidle -w timeout 310 'swaymsg "output * dpms off"' \ resume 'swaymsg "output * dpms on"'
Not ideal, but it seems to work for now.
I think I am having the same issue, but mine isn't convenient to solve with more instances of swayidle.
I have the following command, which handles auto locking my session.
swayidle -w \
timeout 295 'swaymsg output * dpms off' \
timeout 300 'swaylock' \
resume 'swaymsg output * dpms on' \
before-sleep 'playerctl pause' \
before-sleep 'swaylock' &
I also want to have a command which locks the session and then turns off the monitors after 1 second.
I tried to accomplish it by writing a script and something like:
swayidle \
timeout 1 'swaylock' \
timeout 2 'swaymsg "output * dpms off"' \
resume 'swaymsg "output * dpms on"' &&
kill $(ps aux | grep '[s]wayidle timeout 1' | awk '{print $2}')
But I cant make it work properly. What happens is that I come back sometimes, I unlock the session, and it locks again immediately.
I was tryin to makes something like this, but (a) no sure its even a good approach, (b) it doesn't work.
swayidle -w \
timeout 3 'pgrep swaylock && swaymsg output * dpms off' \
resume 'swaymsg output * dpms on' \
timeout 295 'swaymsg output * dpms off' \
timeout 300 'sessionctl lock' \
resume 'swaymsg output * dpms on' \
before-sleep 'playerctl pause' \
before-sleep 'sessionctl instant_lock'
If there was a way to have the following run only for 1 time, and then exit, it would be great:
swayidle \
timeout 1 'swaylock' \
timeout 2 'swaymsg "output * dpms off"' \
resume 'swaymsg "output * dpms on"'
I tried to accomplish it by writing a script and something like ...
That script means "run swaylock whenever I haven't touched the keyboard or mouse for more than one second". If the dpms on takes more than 1 second (it can take a moment), then it might fire before you have time to kill swayidle. Try swapping the order (no, killing swayidle does not kill the child sh
instance), or increase the timeout.
Note that swayidle isn't meant to implement arbitrarily complex rules. If what you want is outside the realm of what swayidle can be distorted into doing, write a tool doing what you need using the idle protocol. swayidle is not using sway specific protocols, it's just a bundled convenience tool.
Thanks for the reply!
That script means "run swaylock whenever I haven't touched the keyboard or mouse for more than one second". If the dpms on takes more than 1 second (it can take a moment), then it might fire before you have time to kill swayidle.
That swayidle command is run from a script, as a background task, with a keybind, and kill
is run immediately after. So the swayidle command is killed immediately after swaylock.
What happens is that the other swayidle command timeout locks runs swaylock again.
I know that this is probably not the place to ask, but like me, someone else is probably looking for the same thing. - Besides auto-locking and turning off the screens after a timeout, I need a way to instantly lock the session and the turn off the monitors. How should I do it?
I need a way to instantly lock the session and the turn off the monitors. How should I do it?
Send SIGUSR1
to swayidle to immediately trigger all timeouts, which can easily be done with killall
. This is referred to in the manpage SIGNALS section.
I need a way to instantly lock the session and the turn off the monitors. How should I do it?
Send
SIGUSR1
to swayidle to immediately trigger all timeouts, which can easily be done withkillall
. This is referred to in the manpage SIGNALS section.
Thanks you for the suggestion. It is really helpful, but what happens if I want to have a sleep timer too?
Edit: I didn't mention it at first, because I was hoping I was doing something wrong, but neither of the following swayidle commands turn the screen off with killall -s SIGUSR1 swayidle . The monitors turn off momentarily, but then they turn back on in an instant.
swayidle -w \
timeout 300 'swaylock -f' \
timeout 305 'swaymsg "output * dpms off"' \
resume 'swaymsg "output * dpms on"' \
before-sleep 'swaylock -f'
swayidle -w \
timeout 300 'swaymsg "output * dpms off"' \
timeout 305 'swaylock -f' \
resume 'swaymsg "output * dpms on"' \
before-sleep 'swaylock -f'
I added a sleep 1
before killall -s SIGUSR1 swayidle
and it locks properly
I tried both, but I made sure they were not running at the same time
same issue please fix it...
same issue please fix it...
Please refrain from posting unconstructive comments. If you wish to show interest, feel free to use the various "reactions" on the main issue.
Thanks you for the suggestion. It is really helpful, but what happens if I want to have a sleep timer too?
Most people have a combined lock + display off, and having it lock and turn displays off simultaneously (which happens when all timouts fire) is not an issue.
Using a version of sway and swaylock with ext-session-lock (until 1.8 is released, that would be master) will make locking generally better.
I added a sleep 1 before killall -s SIGUSR1 swayidle and it locks properly
A sleep shouldn't affect anything.
I am closing this issue, as the things discussed differ from the original (3.5 years old) issue description.
Feel free open new issues for specific observed issues.
Using a version of sway and swaylock with ext-session-lock (until 1.8 is released, that would be master) will make locking generally better.
This is the first time that I hear of that term. I'm using the sway package in the fedora repos and I would be very hesitant to change it.
sessionctl_idle() {
killall swayidle
/usr/bin/swayidle -w \
timeout 295 'loginctl lock-session' \
timeout 300 'swaymsg "output * dpms off"' \
resume 'swaymsg "output * dpms on"' \
timeout 600 'systemctl suspend' \
timeout 5 'if pgrep swaylock; then swaymsg "output * dpms off"; fi' \
resume 'if pgrep swaylock; then swaymsg "output * dpms on"; fi' \
before-sleep 'loginctl lock-session' \
after-resume 'sleep 2 && clamshell' \
lock 'systemctl --user start lock.target' \
unlock 'systemctl --user stop lock.target'
}
The above bash function is what I have been using, after some help from a Redditor. It works, but I had to combine it with systemd services and targets. With an unlock target and service, I kill swaylock
after unlock
, so I never have to unlock to instances of swaylock.
I didn't have the time to set up a way to switch between powered and on-battery modes, but I plan on doing it when I have some time.
I've been having for a while something like: exec swaydile timeout 3600 command line calling swaylock timeout 50 dpms off resume dpms on It seems to work for a while. Now only the last timeout/resume stanza seems processed.
My apologizes if I do things the wrong way.
Thks 4 ur attention.