-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
before-sleep not triggered when systemd-suspend.service
or suspend.target
triggered
#59
Comments
AFAIK the proper way to ask for suspend is |
For context, the reason I had this problem was that I wanted a timer to trigger a suspend, or something like that, which is why I wanted to directly use |
@markstos my bad, thanks for correcting me. So the only difference I can think of is that I just checked and polkit does not allow me to start a target as a user but Anyway that was a 2020 problem so maybe this is not a problem anymore. |
This is an issue for me. I'm specifically using deep sleep (e.g. suspend to RAM), and I believe it was working with non-deep sleep. Here's my config: exec swayidle -w \
timeout 300 'systemctl suspend"' \
resume 'swaymsg "output * dpms on"' \
before-sleep 'swaylock -C ~/.config/swaylock/config' \
lock 'swaylock -C ~/.config/swaylock/config'
bindsym --release $mod+Escape exec systemctl suspend My idea was to trigger systemctl suspend, which would then (theoretically) trigger swaylock. The short cut at least seemed to work when it was non-deep sleep 🤔 |
You can get swayidle to trigger lock by sending SIGUSR1 to it, then wait a moment before suspend. Alternatively start swaylock directly before suspending (not sure how multiple swaylock instances behave these days). As for why swayidle doesn't trigger, if it's on our end then it could be a problem servicing sd-bus (e.g. we only dispatch on readable socket but sd-bus already read into a buffer). |
I went with the route of triggering swaylock before doing anything else: ### Idle configuration
exec swayidle -w \
timeout 300 'swaylock' \
timeout 301 'systemctl suspend' \
after-resume 'swaymsg "output * dpms on"' \
before-sleep 'swaylock' \
lock 'swaylock'
bindsym --release $mod+Escape exec 'swaylock' (Also noting that swaylock is daemonized in its config file.) I could also bind the shortcut to That said, I was also curious, is it necessary to run |
I have created [Unit]
Description=Swayidle to trigger idle actions
Documentation=man:swayidle(1)
PartOf=sway-session.target
After=sway-session.service
[Service]
Type=simple
ExecStart=/usr/bin/swayidle -w \
timeout 600 '\
swaylock --ignore-empty-password \
--image /path/to/wallpaper.jpg' \
timeout 900 'swaymsg "output * dpms off"' \
resume 'swaymsg "output * dpms on"' \
timeout 1800 'systemctl suspend' \
timeout 30 'if pgrep swaylock; then swaymsg "output * dpms off"; fi' \
resume 'if pgrep swaylock; then swaymsg "output * dpms on"; fi' \
before-sleep \
"swaylock --ignore-empty-password \
--image /path/to/wallpaper.jpg"
[Install]
WantedBy=sway-session.target It seems to work pretty well, but it seems like sometimes I have to unlock the session multiple times with correct passwords after I wake the system. I think I see why now. I want to cover two cases:
It looks like in the case where I leave the computer alone, it's running swaylock twice: once due to the timeout and a second time due to the suspend! It looks like @noahtallen is following the same pattern. I checked the |
swayidle version:
1.6
In both of these cases,
swaylock
won't be run.The text was updated successfully, but these errors were encountered: