Flash of desktop screen on laptop resume
Hey,
Gtklock working pretty great for me. However, if I shut my laptop screen and allow it to suspend, when I come back, I get a flash of my desktop windows before gtlock renders itself.
Here is my swayidle configuration:
exec swayidle -w \
timeout 300 'gtklock -d -s ~/.config/gtklock/style.css' \
timeout 600 'swaymsg "output * dpms off"' \
resume 'swaymsg "output * dpms on"' \
after-resume 'gtklock -d -s ~/.config/gtklock/style.css'
I did have that after-resume line as before-sleep at one point, but that failed to invoke gtlock all together.
The flash is probably due to the delay between the laptop resuming and gtklock staring. I can't really do anything about that.
What I'm more worried about is the before-sleep option not working with gtklock. It led me to discover that on my system gtklock just exits if I suspend and resume the device while locked... What's worse is that I found this behaviour in all programs using gtk-layer-shell, but only when using multiple outputs. I want to test this on a different system but don't currently have one on hand.
Maybe this is the same issue that you encountered? Do you have multiple outputs connected when this happens? Can you try starting gtklock by a method other than swayidle and see if it happens?
Hey @jovanlanik
So I just did this test:
- Killed swayidle in my current session
- Plugged in dock so viewing multi-monitor.
- Ran "gtklock" from the CLI directly
- Hopped to new
ttyand forced suspend withsystemctl suspend - Woke computer up, returned to
ttywith Sway.
When I returned gtklock is still running and has kept the locked session, so I'm not exactly noticing this flaw you are.
Also, oddly enough the desktop flash screen only occurs when I'm plugged into my dock with multi-monitors.
Can you also try suspending while sway is still active (without changing to tty)?
- run `$ sleep 5 && systemctl suspend'
- then run gtklock
If I do it your way, it doesn't happen to me either.
Tried your way, I still come back to gtklock. No crash.
While multiple output are connected?
Yup. With multiple monitor outs.
Well I'm confused... I absolutely do not understand why before-sleep doesn't work with gtklock. I'll have to do try installing elogind and try it for myself...
I also don't understand this problem with gtk-layer-shell but until I replicate it on a different system I'll assume it's specific to me.
Ill give it another go in a bit, but AFAICT, it lives over a suspend/resume
I think I pinned down the issue I had as the same as or related to #6, so when I fix that I'll try replicating your issue.
Thanks, looks promising.
Do you by any chance use bindswitch in your sway config?
I do,
bindswitch --reload --locked lid:on output eDP-1 disable
bindswitch --reload --locked lid:off output eDP-1 enable
My laptop display.
I fixed it in the latest commit but it requires some config:
- If you use swayidle, lock using
before-sleep: `$ swayidle -w before-sleep 'gtklock -d'. This way the window is created and rendered before sleep. - Avoid disabling outputs before sleep. In your config
bindswitchdisables eDP-1 even when going to sleep, this shouldn't happen because it destroys window and a new one is only created when the output gets enabled after resume. Unfortunately, I can't do anything else about it. It's a limitation of wlr-layer-shell, the window must close if you disable the output. You can still disable the output in situations where the lid doesn't put the device to sleep. Maybe you can check if the laptop is docked before disabling eDP-1 onbindswitch.
Hmm, AFA point 2 goes, my laptop will only sleep on lid closed if that setting is there. I tried it with a disable dpms setting as well, but that keeps the laptop awake.
I see what youre saying tho. This gets a little tricky while still supporting clamshell mode
That's strange, I also use clamshell and my device sleeps regardless of sway settings. Maybe check /etc/systemd/logind.conf.
Okay let me double check.
May i ask, what are your lid shut settings?
I use the defaults, so the entire file is commented out but I think these are the relevant values:
[Login]
HandleLidSwitch=suspend
HandleLidSwitchExternalPower=suspend
HandleLidSwitchDocked=ignore
LidSwitchIgnoreInhibited=yes
[Sleep]
AllowSuspend=yes
AllowSuspendInterrupts=no
BroadcastSuspendInterrupts=yes
EDIT: some of these options seem specific to elogind and might be different for systemd...
Thats helpful, but i meant for sway config.
Oh, sorry. In my sway config I have:
exec_always exec sway-monitors.sh
bindswitch --locked lid:toggle exec exec sway-monitors.sh
And in the sway-monitors.sh script I check if the laptop is docked by connected devices:
#!/bin/sh
# Specific to my setup
docked() {
lspci -n | grep -q '1002:67df' && return 0
lsusb | grep -q '258a:0036' && return 0
return 1
}
docked || exit
if grep -q open /proc/acpi/button/lid/LID/state
then
swaymsg output eDP-1 enable
else
swaymsg output eDP-1 disable
fi
Ohh nice example. Thanks a lot! Ill give this ago in a bit
The part that checks dock is really specific to my setup, so you might have to change it up a little...
Yup, ill find the Guids
Now that I think about it, a better check would be checking the number of available outputs using swaymsg...
EDIT: something like swaymsg -t get_outputs | jq '. | length'. If it equals 1 then you're not docked.
I've had some problems with the script... When suspending, undocking and resuming the output would stay disabled. Updated script:
#!/bin/sh
# Specific to my setup
docked() {
lspci -n | grep -q '1002:67df' && return 0
lsusb | grep -q '258a:0036' && return 0
return 1
}
if grep -q open /proc/acpi/button/lid/LID/state
then
swaymsg output eDP-1 enable
else
docked && swaymsg output eDP-1 disable
fi
Alternative docking function:
# More universal but depends on jq
docked() {
[ "$(swaymsg -t get_outputs | jq '. | length')" -ne 1 ] && return 0
return 1
}
I'm closing this issue because it not currently (and as long as gtklock can't use ext-session-lock) possible to fix but can be mostly avoided by never disabling all outputs.