GNU bug report logs - #77806
elogind behavior changed: power key turns computer off

Previous Next

Package: guix;

Reported by: Ludovic Courtès <ludo <at> gnu.org>

Date: Mon, 14 Apr 2025 16:48:02 UTC

Severity: important

Done: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#77806: closed (elogind behavior changed: power key turns
 computer off)
Date: Sat, 26 Apr 2025 14:04:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Sat, 26 Apr 2025 23:03:09 +0900
with message-id <87h62bdnqa.fsf_-_ <at> gmail.com>
and subject line Re: bug#77806: elogind behavior changed: power key turns computer off
has caused the debbugs.gnu.org bug report #77806,
regarding elogind behavior changed: power key turns computer off
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
77806: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=77806
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Ludovic Courtès <ludo <at> gnu.org>
To: bug-guix <at> gnu.org
Subject: elogind behavior changed: power key turns computer off
Date: Mon, 14 Apr 2025 18:46:33 +0200
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’.


[Message part 3 (message/rfc822, inline)]
From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: Josselin Poiret <dev <at> jpoiret.xyz>, Vivien Kraus <vivien <at> planete-kraus.eu>,
 Noé Lopez <noelopez <at> free.fr>,
 Liliana Marie Prikler <liliana.prikler <at> gmail.com>,
 Bas Alberts <bas <at> anti.computer>, 77806-done <at> debbugs.gnu.org
Subject: Re: bug#77806: elogind behavior changed: power key turns computer off
Date: Sat, 26 Apr 2025 23:03:09 +0900
Hi,

Ludovic Courtès <ludo <at> gnu.org> writes:

> Hi,
>
> Maxim Cournoyer <maxim.cournoyer <at> gmail.com> 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 <at> terra ~$ cat /gnu/store/hqbmn9idlydkkm554k1zrhi306ffsldl-sleep.conf
[Sleep]
SuspendState=mem standby freeze
SuspendEstimationSec=3600
HibernateMode=platform shutdown
maxim <at> 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 <at> terra ~$ readlink /etc/elogind/logind.conf.d/logind.conf
/gnu/store/z2hdrmyxjd0x7msf66638ppl9hx99fh3-logind.conf
maxim <at> 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


This bug report was last modified 76 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.