Subject: bug#77806: closed (Re: bug#77806: elogind behavior changed: power key turns computer off)

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 26 Apr 2025 14:04:03 +0000

Your bug report

#77806: elogind behavior changed: power key turns computer off

which was filed against the guix package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
77806: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=77806
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#77806: elogind behavior changed: power key turns computer off
From: Maxim Cournoyer <[email-masked]>
To: Ludovic Courtès <[email-masked]>
Cc: Josselin Poiret <[email-masked]>, Vivien Kraus <[email-masked]>,Noé Lopez <[email-masked]>, Liliana Marie Prikler <[email-masked]>, Bas Alberts <[email-masked]>, [email-masked]
Date: Sat, 26 Apr 2025 23:03:09 +0900
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi,

Ludovic Courtès <[email-masked]> writes:

> Hi,
>
> Maxim Cournoyer <[email-masked]> writes:
>
>> Fixes: bug#77806
>
> I would provide the complete URL, as is usually done, to avoid
> ambiguity.

Okay, done.

>> +         (actions (list (shepherd-configuration-action
>> +                         "/etc/elogind/logind.conf"))))))
>
> Would it be possible to give the config file name in the store instead?
> That way, we would know which one is actually in effect (when one
> reconfigures, /etc/logind/logind.conf is changed through activation but
> elogind keeps honoring the previous version of it, which is why
> distinguishing between both can be helpful IMO.)

I did what you had suggested earlier with a custom
'shepherd-configuration-action' job that accepts multiple files:

--8<---------------cut here---------------start------------->8---
1 file changed, 13 insertions(+), 2 deletions(-)
gnu/services/desktop.scm | 15 +++++++++++++--

modified   gnu/services/desktop.scm
@@ -1505,6 +1505,16 @@ (define (pam-extension-procedure config)
              (session (cons pam-elogind (pam-service-session pam))))))
          (shepherd-requirements '(elogind)))))
 
+(define* (shepherd-configuration-action* files)
+  "Return a 'configuration' action to display FILES, which should be the names
+of the service's configuration files."
+  (shepherd-action
+   (name 'configuration)
+   (documentation "Display the names of this service's configuration files.")
+   (procedure #~(lambda (_)
+                  (format #t "~{~a~%~}" '#$files)
+                  '#$files))))
+
 (define (elogind-shepherd-service config)
   "Return a Shepherd service to start elogind according to @var{config}."
   (list (shepherd-service
@@ -1514,8 +1524,9 @@ (define (elogind-shepherd-service config)
                    (list #$(file-append (elogind-configuration-elogind config)
                                         "/libexec/elogind/elogind"))))
          (stop #~(make-kill-destructor))
-         (actions (list (shepherd-configuration-action
-                         "/etc/elogind/logind.conf"))))))
+         (actions (list (shepherd-configuration-action*
+                         (list (logind.conf config)
+                               (sleep.conf config))))))))
 
 (define elogind-service-type
   (service-type
--8<---------------cut here---------------end--------------->8---

And it seems to work correctly on my machine:

--8<---------------cut here---------------start------------->8---
$ sudo herd configuration elogind
/gnu/store/z2hdrmyxjd0x7msf66638ppl9hx99fh3-logind.conf
/gnu/store/hqbmn9idlydkkm554k1zrhi306ffsldl-sleep.conf
maxim@terra ~$ cat /gnu/store/hqbmn9idlydkkm554k1zrhi306ffsldl-sleep.conf
[Sleep]
SuspendState=mem standby freeze
SuspendEstimationSec=3600
HibernateMode=platform shutdown
maxim@terra ~$ find /etc/elogind/
/etc/elogind/
/etc/elogind/logind.conf.d
/etc/elogind/logind.conf.d/logind.conf
/etc/elogind/sleep.conf.d
/etc/elogind/sleep.conf.d/sleep.conf
maxim@terra ~$ readlink /etc/elogind/logind.conf.d/logind.conf
/gnu/store/z2hdrmyxjd0x7msf66638ppl9hx99fh3-logind.conf
maxim@terra ~$ readlink /etc/elogind/sleep.conf.d/sleep.conf
/gnu/store/hqbmn9idlydkkm554k1zrhi306ffsldl-sleep.conf
--8<---------------cut here---------------end--------------->8---

Josselin pointed to some problem, which I've now fix (had to use
"drop-ins" files instead of the canonical config file names, which are
looked from the package's sysconfdir in the store instead of under
/etc/elogind).  If we find other we can fix them later, but it seems to
me it can't be much worst than it is now, so I've now pushed this to
master, with commit f10d00e4e25.

Thanks to everyone who helped figure that one out!

-- 
Thanks,
Maxim

Subject: elogind behavior changed: power key turns computer off
From: Ludovic Courtès <[email-masked]>
To: [email-masked]
Date: Mon, 14 Apr 2025 18:46:33 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello,

Probably related to the elogind upgrade in
098b5cdf9c6841df0b3c086974eef7e13fd23b36, I noticed today that pressing
the power button on my laptop would turn it off instead of putting it
into software suspend as it used to do:

--8<---------------cut here---------------start------------->8---
2025-04-14 17:59:53 localhost elogind[290]: Power key pressed short.
2025-04-14 17:59:53 localhost elogind[290]: Powering off...
2025-04-14 17:59:53 localhost elogind[290]: System is powering down.
2025-04-14 17:59:54 localhost shepherd[1]: Stopping service root...
2025-04-14 17:59:54 localhost shepherd[1]: Exiting shepherd...
2025-04-14 17:59:54 localhost shepherd[1]: Stopping service swap-/swap...
2025-04-14 17:59:54 localhost shepherd[1]: Service swap-/swap stopped.
2025-04-14 17:59:54 localhost shepherd[1]: Service swap-/swap is now stopped.
--8<---------------cut here---------------end--------------->8---

Previously I had:

--8<---------------cut here---------------start------------->8---
2025-04-08 18:07:51 localhost elogind[282]: Power key pressed short.
2025-04-08 18:07:51 localhost elogind[282]: Suspending...
2025-04-08 18:07:51 localhost NetworkManager[311]: <info>  [1744128471.3311] manager: sleep: sleep requested (sleeping: no  enabled: yes)
2025-04-08 18:07:51 localhost NetworkManager[311]: <info>  [1744128471.3332] manager: NetworkManager state is now ASLEEP
2025-04-08 18:07:51 localhost elogind[282]: Entering sleep state 'suspend'...
2025-04-08 18:07:51 localhost linux: [82930.856145] PM: suspend entry (deep)
--8<---------------cut here---------------end--------------->8---

Yet the config reads this:

--8<---------------cut here---------------start------------->8---
$ grep -i powerkey $(sudo herd configuration elogind)
HandlePowerKey=suspend
PowerKeyIgnoreInhibited=no
--8<---------------cut here---------------end--------------->8---

Thoughts?

Ludo’.