swaywm/swayidle

unlock event not triggered

skaldesh opened this issue · 3 comments

For testing purposes, I am executing the following swayidle command in my terminal:
swayidle -w timeout 5 'swaymsg "output * dpms off" ; echo "timeout"' resume 'swaymsg "output * dpms on" ; echo "resume"' unlock 'echo "unlock" ; pkill swayidle' lock 'echo "lock" ; swaylock -f'

In my sway config, I have this binding to lock my session:
bindsym $mod+Ctrl+l exec "loginctl lock-session"

After locking, waiting 5 seconds, then entering the password, the following gets printed:

  1. lock
  2. timeout
  3. resume

I am missing the unlock message. Am I doing something wrong here?

EDIT: I just realized that maybe I should have created this issue for swaylock. I guess the unlock for swayidle is only triggered, when loginctl unlock-session is called by swaylock.

If you call lock-session, you must also call unlock-session. Swaylock does not talk to logind, it just checks your password through PAM.

You only need to use the swayidle logind event listeners if you want to listen to existing logind changes.

Ah ok, I did not fully understand how swaylock works. thanks for clarifying that.

My solution is now to do: swayidle -w timeout 5 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on" ; echo "resume"' lock 'echo "lock" ; { swaylock ; pkill swayidle ; } &'
That way, once swaylock finishes, takes down swayidle with it.

If there is a simpler way though, I would be glad to learn it.

Found it myself:
swayidle -w timeout 5 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"' & swaylock ; pkill swayidle
avoids logind completetly. Thanks @kennylevinsen