Re: Sway not locked after resume

From: Renato Botelho <garga_at_FreeBSD.org>
Date: Thu, 15 May 2025 16:04:30 UTC
On 15/05/25 12:49, Adrian Chadd wrote:
> 
> 
> On Thu, 15 May 2025 at 08:06, Renato Botelho <garga@freebsd.org 
> <mailto:garga@freebsd.org>> wrote:
> 
>     On 15/05/25 11:58, Adrian Chadd wrote:
>      >
>      >
> 
>      >     BTW, I was running drm-66-kmod and now I moved to drm-61-
>     kmod.  No
>      >     changes at all.
>      >
>      >
>      > Can you add some debugging to see if the right events are being
>     generated?
> 
>     I replaced command used on before-sleep parameter of swayidle to
>     touch a
>     file on /tmp and file never show up.  What else can I do to debug?
> 
> 
> Hm, how's it registering for before-sleep and resume messages? Are they 
> xf86 events?

Sway runs only on Wayland, no xf86 involved.  Anyway, the software used 
to deal with that is not sway, but swayctl.

DESCRIPTION
      swayidle listens for idle activity on your Wayland compositor and
      executes tasks on various idle-related events. You can specify any 
number
      of events at the command line and in the config file.

One available idle acticity is before-sleep

before-sleep <command>
     If built with ConsoleKit2 support, executes command before
     ConsoleKit2 puts the computer to sleep.

     Note: this only delays sleeping up to the limit set in logind.conf(5)
     by the option InhibitDelayMaxSec. A command that has not finished by
     then will continue running after resuming from sleep.

Parameters used on my setup are the default ones from default sway 
config file, it calls `swaylock` on `before-sleep` event.

I replaced swaylock by `touch /tmp/before-sleep` and this file was never 
created, what means before-sleep parameter is not being executed.

I've added jbeich (swayidle maintainer) to the CC list, case they have 
any idea about what could be wrong.

I'll check swayidle source code and see how to debug it.

> We may need to go into the sway source code to see what's going on.
> 
> 
> -adrian
> 
> 
>      >      >
>      >      >
>      >      >
>      >      > -adrian
>      >      >
>      >      >
>      >      > On Thu, 15 May 2025 at 05:56, Renato Botelho
>     <garga@freebsd.org <mailto:garga@freebsd.org>
>      >     <mailto:garga@freebsd.org <mailto:garga@freebsd.org>>
>      >      > <mailto:garga@freebsd.org <mailto:garga@freebsd.org>
>     <mailto:garga@freebsd.org <mailto:garga@freebsd.org>>>> wrote:
>      >      >
>      >      >     I've installed a fresh 15-CURRENT on a thinkpad E14
>     and setup
>      >     a simple
>      >      >     sway desktop.  After resuming from S3 suspend it comes
>     back
>      >     unlocked.
>      >      >
>      >      >     I have swayidle running as follow:
>      >      >
>      >      >     swayidle -w \
>      >      >                timeout 300 'swaylock -f -c 000000' \
>      >      >                timeout 600 'swaymsg "output * dpms off"' \
>      >      >                resume 'swaymsg "output * dpms on"' \
>      >      >                before-sleep 'swaylock -f -c 000000'
>      >      >
>      >      >     swaylock is executed as expected by timeout parameter
>     but it
>      >     looks like
>      >      >     it's not being executed by before-sleep call.
>      >      >
>      >      >     There are some messages about failures to find session on
>      >     swayidle
>      >      >     debug
>      >      >     output
>      >      >
>      >      >     2025-05-15 09:50:24 - [Line 903] Got timeout
>      >      >     2025-05-15 09:50:24 - [Line 750] Register idle timeout at
>      >     300000 ms
>      >      >     2025-05-15 09:50:24 - [Line 751] Setup idle
>      >      >     2025-05-15 09:50:24 - [Line 713] Command: swaylock -f
>     -c 000000
>      >      >     2025-05-15 09:50:24 - [Line 903] Got timeout
>      >      >     2025-05-15 09:50:24 - [Line 750] Register idle timeout at
>      >     600000 ms
>      >      >     2025-05-15 09:50:24 - [Line 751] Setup idle
>      >      >     2025-05-15 09:50:24 - [Line 713] Command: swaymsg
>     "output *
>      >     dpms off"
>      >      >     2025-05-15 09:50:24 - [Line 756] Setup resume
>      >      >     2025-05-15 09:50:24 - [Line 713] Command: swaymsg
>     "output *
>      >     dpms on"
>      >      >     2025-05-15 09:50:24 - [Line 906] Got before-sleep
>      >      >     2025-05-15 09:50:24 - [Line 713] Command: swaylock -f
>     -c 000000
>      >      >     2025-05-15 09:50:24 - [Line 778] Setup sleep lock:
>     swaylock -
>      >     f -c 000000
>      >      >     2025-05-15 09:50:24 - [Line 1078] No config file found.
>      >      >     2025-05-15 09:50:24 - [Line 440] GetSession failed:
>     Unable to
>      >     find
>      >      >     session for ID
>      >      >     2025-05-15 09:50:24 - [Line 449] GetSessionByPID failed:
>      >     Unable to
>      >      >     lookup session information for process '9062'
>      >      >     2025-05-15 09:50:24 - [Line 451] Failed to find session
>      >      >     2025-05-15 09:50:24 - [Line 223] Got sleep lock: 12
>      >      >     2025-05-15 09:50:24 - [Line 282] Failed to parse get
>      >     BlockInhibited
>      >      >     property: Invalid argument
>      >      >     2025-05-15 09:50:24 - [Line 621] Enable idle timeouts
>      >      >     2025-05-15 09:50:24 - [Line 596] Register with
>     timeout: 600000
>      >      >     2025-05-15 09:50:24 - [Line 596] Register with
>     timeout: 300000
>      >      >
>      >      >     I have seatd and dbus running, my user is member of
>     video group,
>      >      >     XDG_RUNTIME_DIR set and sway was launched by ly DM.  /etc/
>      >     sysctl.conf
>      >      >     has only one special entry
>      >      >
>      >      >     hw.acpi.lid_switch_state=S3
>      >      >
>      >      >     Is anyone experiencing such problems?  Any thoughts about
>      >     what could be
>      >      >     causing it?
>      >      >
>      >      >     Thanks!
>      >      >     --
>      >      >     Renato Botelho
>      >      >
>      >      >
>      >
>      >
>      >     --
>      >     Renato Botelho
>      >
> 
> 
>     -- 
>     Renato Botelho
>