From unknown Thu Jun 19 13:54:41 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#77806 <77806@debbugs.gnu.org> To: bug#77806 <77806@debbugs.gnu.org> Subject: Status: elogind behavior changed: power key turns computer off Reply-To: bug#77806 <77806@debbugs.gnu.org> Date: Thu, 19 Jun 2025 20:54:41 +0000 retitle 77806 elogind behavior changed: power key turns computer off reassign 77806 guix submitter 77806 Ludovic Court=C3=A8s severity 77806 important thanks From debbugs-submit-bounces@debbugs.gnu.org Mon Apr 14 12:47:05 2025 Received: (at submit) by debbugs.gnu.org; 14 Apr 2025 16:47:05 +0000 Received: from localhost ([127.0.0.1]:48690 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u4Mxc-000695-KL for submit@debbugs.gnu.org; Mon, 14 Apr 2025 12:47:04 -0400 Received: from lists.gnu.org ([2001:470:142::17]:44642) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u4MxY-00068Q-Ic for submit@debbugs.gnu.org; Mon, 14 Apr 2025 12:47:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u4MxQ-0006ON-UU for bug-guix@gnu.org; Mon, 14 Apr 2025 12:46:52 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u4MxQ-0007cD-J3 for bug-guix@gnu.org; Mon, 14 Apr 2025 12:46:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:Subject:To:From:in-reply-to: references; bh=GIOq4RjAjvK2X0Sc+bJLsu4msXWo/uZkid0bwajsN5w=; b=kjpAGguPwuexPD 22wX1/tFt6m4O1OLmOM9nmWeqQC1OLRpwwURGhuNpMz6trWU6s4y9x+InAGNkcQtXjr+OVsdie95J N7FWTEvV2wEYU4gLrtHaCvnd0CVZG2VF/TSIRBoDzRx4UciAY3bi4jszVieyto+PFDEA+Msx98ezR pIt8vKy9SPAbsqJG2xbh+LfaGHDakOZdcOvhcgR6LKFho9W8gNjXVJefwRRKXIAwWvlHwuIHQRd1+ 9NCD99UpDVKxw4j3CAIbW8oI1fFl9SF72/OF9lJCSnPKuEo6nwR1mwKIAFrqo0797HK0YWV+qtmAY S3yuPpTUgn/EUmhYWD3g==; From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: bug-guix@gnu.org Subject: elogind behavior changed: power key turns computer off User-Agent: mu4e 1.12.9; emacs 29.4 X-Debbugs-Cc: Maxim Cournoyer X-URL: https://people.bordeaux.inria.fr/lcourtes/ X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu X-Revolutionary-Date: Quintidi 25 Germinal an 233 de la =?utf-8?Q?R=C3=A9v?= =?utf-8?Q?olution=2C?= jour du Pigeon Date: Mon, 14 Apr 2025 18:46:33 +0200 Message-ID: <87v7r6ofme.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) 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 stoppe= d. --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]: [1744128471.3311= ] manager: sleep: sleep requested (sleeping: no enabled: yes) 2025-04-08 18:07:51 localhost NetworkManager[311]: [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=3Dsuspend PowerKeyIgnoreInhibited=3Dno --8<---------------cut here---------------end--------------->8--- Thoughts? Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 15 23:03:51 2025 Received: (at 77806) by debbugs.gnu.org; 16 Apr 2025 03:03:51 +0000 Received: from localhost ([127.0.0.1]:59758 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u4t42-00017c-VH for submit@debbugs.gnu.org; Tue, 15 Apr 2025 23:03:51 -0400 Received: from mail-10624.protonmail.ch ([79.135.106.24]:42277) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u4t3u-00015Y-Lb for 77806@debbugs.gnu.org; Tue, 15 Apr 2025 23:03:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anti.computer; s=protonmail2; t=1744772612; x=1745031812; bh=xV3h86HMZENLbXGgbSQycHf1NpGMedKdZS2bS9Xmoxc=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post; b=j3+AIDw6Rdt4RCH6LQCiD3DdajbA9ruduR41JQEF7Jy23aMx766y/2mVAQ2fvhCrK wHJrrXMhH5VtYNT4NdV5qQHst7eJhueu1qViJ32HlnI7eZZKrCJGGrrPoeA5HNzXhg I1640Zj82ZSWkxoPUUKBF2Lz3MQN9HItS5UPUXOUcM0RM5fgscZ9DhOS/2+Vz38/nc 2Df2o8Qd+Q5YfzgKaWI0BulW77QF0mL5U1pqu1RhMNNMDHQ7EICuwWqphEd13y9OrE 7qx+nhPEH7JNiPMsglXHY5Vbg92YkwQK7EDKz6bRweECqHoOpgP+umVqoHbx+wxQoM 455NypBaSvg8Q== Date: Wed, 16 Apr 2025 03:03:28 +0000 To: =?utf-8?Q?Ludovic_Court=C3=A8s?= From: Bas Alberts Subject: Re: bug#77806: elogind behavior changed: power key turns computer off Message-ID: In-Reply-To: <87v7r6ofme.fsf@gnu.org> References: <87v7r6ofme.fsf@gnu.org> Feedback-ID: 9830402:user:proton X-Pm-Message-ID: cebc757b04c0671a30340995b9912dcceb493e44 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 77806 Cc: Maxim Cournoyer , 77806@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On Mon, 14 Apr 2025 18:46:33 +0200,=20 Ludovic Court=C3=A8s wrote: > > Yet the config reads this: > > $ grep -i powerkey $(sudo herd configuration elogind) > HandlePowerKey=3Dsuspend > PowerKeyIgnoreInhibited=3Dno I'm having the same issue. My config is also unchanged but after this week's upgrades elogind no longer respects HandleLidSwitch=3Dhibernate and my laptop defaults to s2idle which is prohibitively battery consuming on my hardware. =CE=BB ~ =E2=80=BA grep -i HandleLidSwitch=3D $(sudo herd configuration elo= gind) HandleLidSwitch=3Dhibernate ... on lid close: [ 3603.354720] PM: suspend entry (s2idle) [ 3603.359069] Filesystems sync: 0.004 seconds [ 3603.368060] Freezing user space processes ... Kind regards, Bas From debbugs-submit-bounces@debbugs.gnu.org Fri Apr 18 16:50:35 2025 Received: (at control) by debbugs.gnu.org; 18 Apr 2025 20:50:36 +0000 Received: from localhost ([127.0.0.1]:53067 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u5sfS-0002do-EE for submit@debbugs.gnu.org; Fri, 18 Apr 2025 16:50:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46030) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u5sfK-0002ZS-Js for control@debbugs.gnu.org; Fri, 18 Apr 2025 16:50:30 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u5sfF-0000Ce-2s for control@debbugs.gnu.org; Fri, 18 Apr 2025 16:50:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:Subject:From:To:Date:in-reply-to: references; bh=/gFMPQB3ct9cyDVxjQ83tG3P6UAX7VV6PGCUreq11Bc=; b=QuxFXw8uQBLMex r2Xk+TFbPtjIacyiLDuPdW9BR5e+SuBj/fv5v41AKS4J9ZNMbNh/+AANhrOrNL5M29loHAHokdcpl x1RP2UaZvrRlsx5+bdtijypc4NmWocbyetl4qb1q+Lii6Wpt0NgPe1xwL3WRw2/c2UW3CTux8FCOo lXVsxLp3eAdZc6QrOiZ2HblfXcrMEdrEXUi2O0T6+3SYSZCRZ6mk2kbgg9rJzjAoGtp4OGWooupWK uSz5jG8Kl5X5RZEp0S5csT28NrPK1Ym+yM1GK/Dd73teA+QAF7SyiwSnukVIgOavkBGG+CKElIkru yU0tc+CBoT0MlVI4frKw==; Date: Fri, 18 Apr 2025 22:31:11 +0200 Message-Id: <87tt6li54g.fsf_-_@gnu.org> To: control@debbugs.gnu.org From: =?utf-8?Q?Ludovic_Court=C3=A8s?= Subject: control message for bug #77806 MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) severity 77806 important quit From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 24 01:29:38 2025 Received: (at 77806) by debbugs.gnu.org; 24 Apr 2025 05:29:38 +0000 Received: from localhost ([127.0.0.1]:33725 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u7p9V-0001Is-SH for submit@debbugs.gnu.org; Thu, 24 Apr 2025 01:29:38 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]:58513) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1u7p9T-0001IV-Np for 77806@debbugs.gnu.org; Thu, 24 Apr 2025 01:29:36 -0400 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-7376dd56eccso578558b3a.0 for <77806@debbugs.gnu.org>; Wed, 23 Apr 2025 22:29:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745472569; x=1746077369; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=uWJT/7rHz6OjLsPTzi2KoOcW+yxda75nhTaa83GOngk=; b=crDq3Sbzqw2XaPWye5O98s/0Pk8bKJrnyo+hUg1dOzlknWj76yiSUMY1CrI3UGVNUr 11QZ4y9oAh9FNCfLf2KavlC6NbqA21bIOpiq0zqWZM7YdSdWiDuI0cLh9XQvBWGVa789 PJz8832aoW5tHCDk/ldBwI8w8Q4Y5bqsBW4VWsBFwCkECYiI3SnZADeNm2Xi9rfZDhZr JgbxEZ/Gce3ClrchZWdgbh1iR4TH0+Eke8c/H61Ch5heYOch63fQi1Y2MNZQcGLVDhjg RcE3cMH72I7JGzu+m9p3ZaTkSZ4TT0Vl0kEYfiJCnU0iSivtSGFJhvszlSR+9ZoE1DMp oCjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745472569; x=1746077369; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=uWJT/7rHz6OjLsPTzi2KoOcW+yxda75nhTaa83GOngk=; b=gndDZJ61f3inmafw5NSqCd9lR7dyU73mG73Mh52A9FQ1zn2ORTnOllKggxGCM2Afvm uYLLpl/zg2lRRSQ2y5dZBlfTjYsq5fboOTJi0x8l5dDW4wii7Mgedt1u8YgqMvhYboAO C4aLwxg+wWS9Ltvnp1BraRoFZZ1pgHc6WrVuTpk8hV30F5/vgJM+s7XEQCOJMaZf0zXd oNdkJLxXo3x6U3kiDOIGb4vX7uCNHOXSyJxA+73JIhQ2L6UG0qtE4CHLFQTQ0D04wf7D 4xJjyN1TuVvKJUcyG+KD0enCMwgmiRTP4w0QVQqb8o0k0Uq7Z7r1aJFAAOY3AlSE8/7V hJ1Q== X-Forwarded-Encrypted: i=1; AJvYcCW3Yy5jPwRZkq9JHYgvJ3vIuwbKYsvlEhi2ZcJvAUk56CK5bqrId8+nd/UNP7soMm35Pld8WA==@debbugs.gnu.org X-Gm-Message-State: AOJu0Yya8dBSSweyDYd6ae3sRU3rOYYO1H11hBaXhjt/TOrJBa44bHRo DDzwbhEtbt3vr1lplb5Q8h0+TP6niy5pwJhFOaeSmUa0pyhUNnPuXiwzpqDs X-Gm-Gg: ASbGncu1h4Ag5kk4JdNLbkbUQZ/8Xc9m/H56aoqhAJDuT/9kN4/UZxYwQhuLOOIXC4H MtgOh1pyFlQJQ3mpL2F5yY+V2n/fcmLIe15+kfIqGi8+cn4z7B4/+8gyfytend8V5MZGXi76Mu0 SSdDlnJvnq2JLkZXT1VeWX9x51xq0bY+cJdE25+qi8WwV4TSW6OGu2zyW5cZFDi9ENkF3LrktoV 6icf2wKlbSnYK6I0Xyy25O7YcYFo3UW/BRROZcliSxgpf8/KpDWuO/INE8oXbKsYeQ3IWOFbloT 36wlJcEbYSM2/rSf1alHpW+YtFoSX6QEqctZIQ8= X-Google-Smtp-Source: AGHT+IGEnmk7aQQ77OgZoOBqtOpriH847eddCmQNh9EfgVtbSJOftlGnlOlLk3d1/Rha5rzyYqnEIw== X-Received: by 2002:a05:6a21:e590:b0:1f5:8d91:293a with SMTP id adf61e73a8af0-20444fc3288mr1951074637.41.1745472568985; Wed, 23 Apr 2025 22:29:28 -0700 (PDT) Received: from terra ([2405:6586:be0:0:83c8:d31d:2cec:f542]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-b15fadec8c0sm414570a12.68.2025.04.23.22.29.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Apr 2025 22:29:28 -0700 (PDT) From: Maxim Cournoyer To: Bas Alberts Subject: Re: bug#77806: elogind behavior changed: power key turns computer off In-Reply-To: (Bas Alberts's message of "Wed, 16 Apr 2025 03:03:28 +0000") References: <87v7r6ofme.fsf@gnu.org> Date: Thu, 24 Apr 2025 14:29:24 +0900 Message-ID: <87selyrutn.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 77806 Cc: Ludovic =?utf-8?Q?Court=C3=A8s?= , 77806@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi, Thanks for the report. It looks like nowadays the sleep settings are expected to be in a distinct sleep.conf file [0]; I haven't verified yet but I suspect the [Sleep] section of our logind.conf is no longer honored. [0] https://github.com/elogind/elogind/issues/293 -- Thanks, Maxim From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 24 06:39:04 2025 Received: (at 77806) by debbugs.gnu.org; 24 Apr 2025 10:39:05 +0000 Received: from localhost ([127.0.0.1]:36663 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u7tyr-0007AZ-OO for submit@debbugs.gnu.org; Thu, 24 Apr 2025 06:39:03 -0400 Received: from jpoiret.xyz ([159.223.231.69]:54146) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u7tyg-00079x-Vf for 77806@debbugs.gnu.org; Thu, 24 Apr 2025 06:38:53 -0400 From: Josselin Poiret DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1745491123; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Igik90u3Y/+m+MI52GCcLCM8+wWBNw9YSPd+FnaXVLY=; b=SlYlKDPAJYuMmoQ7vERTnvE8M/uHtDDNxekduaSo25lWhJ35ZrlBJi/EBKrKoVXTksgcHi LfkCXiOBDqNSjH9wBiLQsGrZ7Fu5swQovAEa5Smm6FUK1kH/crbFQKOqSY360SEqh0E0Iu XyyvyvO6/oNNnE3jiFz5uUlElAi5Y0+do+JpkcikrwfB/8VC6XaBArkfGGpdxkfXJvVt1G i2ze4/F8ZNflNh5p5hc2vWSIfqqg56PSmQEo23skxbSnDJzRCp/Uh9pZDC6RFeCvqf+J7u dtdE2NaJFxZ5IdUkjwkaXOJZXqMJZxA6kP/CpwrIeM0vTqDIY0R9kmW9Fdmkdw== Authentication-Results: jpoiret.xyz; auth=pass smtp.mailfrom=dev@jpoiret.xyz To: Maxim Cournoyer , Bas Alberts Subject: [PATCH] gnu: elogind-service-type: Put user configuration in drop-in dirs. Date: Thu, 24 Apr 2025 12:38:41 +0200 Message-ID: <3fc9c5b32e713320751ab52d90b3c66a37b025ec.1745490871.git.dev@jpoiret.xyz> In-Reply-To: <87selyrutn.fsf@gmail.com> References: <87selyrutn.fsf@gmail.com> MIME-Version: 1.0 X-Debbugs-Cc: Liliana Marie Prikler , Maxim Cournoyer , Noé Lopez , Vivien Kraus Content-Transfer-Encoding: 8bit X-Spamd-Bar: ++ X-Spam-Level: ** X-Spam-Score: 2.5 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Josselin Poiret * gnu/services/desktop.scm (elogind-configuration-files): Renamed from elogind-configuration-file. Split sections [Login] and [Sleep] in two files. (elogind-shepherd-service): Remove useless environme [...] Content analysis details: (2.5 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_VALIDITY_RPBL_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [159.223.231.69 listed in bl.score.senderscore.com] 0.0 RCVD_IN_VALIDITY_SAFE_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [159.223.231.69 listed in sa-trusted.bondedsender.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: jpoiret.xyz (xyz)] -0.0 SPF_PASS SPF: sender matches SPF record 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD X-Debbugs-Envelope-To: 77806 Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= , Josselin Poiret , 77806@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.5 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Josselin Poiret * gnu/services/desktop.scm (elogind-configuration-files): Renamed from elogind-configuration-file. Split sections [Login] and [Sleep] in two files. (elogind-shepherd-service): Remove useless environme [...] Content analysis details: (1.5 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_VALIDITY_SAFE_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [159.223.231.69 listed in sa-trusted.bondedsender.org] 0.0 RCVD_IN_VALIDITY_RPBL_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [159.223.231.69 listed in bl.score.senderscore.com] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: jpoiret.xyz (xyz)] -0.0 SPF_PASS SPF: sender matches SPF record 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager From: Josselin Poiret * gnu/services/desktop.scm (elogind-configuration-files): Renamed from elogind-configuration-file. Split sections [Login] and [Sleep] in two files. (elogind-shepherd-service): Remove useless environment variable. Change-Id: Ibb4db04152c397c1ed4a35118129a2860ac9c2b5 --- Hello everyone, Here's a fix I just tested. I chose to use drop-in directories instead of the main conf file as it uses an hardcoded PKGCONFDIR. Best, Josselin gnu/services/desktop.scm | 110 ++++++++++++++++++++------------------- 1 file changed, 57 insertions(+), 53 deletions(-) diff --git a/gnu/services/desktop.scm b/gnu/services/desktop.scm index fe034cfa8f4..628879c73dd 100644 --- a/gnu/services/desktop.scm +++ b/gnu/services/desktop.scm @@ -1101,7 +1101,7 @@ (define-record-type* elogind-configuration (broadcast-suspend-interrupts? elogind-broadcast-suspend-interrupts? (default #t))) -(define (elogind-configuration-file config) +(define (elogind-configuration-files config) (define (yesno x) (match x (#t "yes") @@ -1152,55 +1152,59 @@ (define (elogind-configuration-file config) (string-append str "\n"))))) (define-syntax-rule (ini-file config file clause ...) (plain-file file (string-append (ini-file-clause config clause) ...))) - (ini-file - config "logind.conf" - "[Login]" - ("KillUserProcesses" (yesno elogind-kill-user-processes?)) - ("KillOnlyUsers" (user-name-list elogind-kill-only-users)) - ("KillExcludeUsers" (user-name-list elogind-kill-exclude-users)) - ("InhibitDelayMaxSec" (non-negative-integer elogind-inhibit-delay-max-seconds)) - ("HandlePowerKey" (handle-action elogind-handle-power-key)) - ("HandleSuspendKey" (handle-action elogind-handle-suspend-key)) - ("HandleHibernateKey" (handle-action elogind-handle-hibernate-key)) - ("HandleLidSwitch" (handle-action elogind-handle-lid-switch)) - ("HandleLidSwitchDocked" (handle-action elogind-handle-lid-switch-docked)) - ("HandleLidSwitchExternalPower" (handle-action elogind-handle-lid-switch-external-power)) - ("PowerKeyIgnoreInhibited" (yesno elogind-power-key-ignore-inhibited?)) - ("SuspendKeyIgnoreInhibited" (yesno elogind-suspend-key-ignore-inhibited?)) - ("HibernateKeyIgnoreInhibited" (yesno elogind-hibernate-key-ignore-inhibited?)) - ("LidSwitchIgnoreInhibited" (yesno elogind-lid-switch-ignore-inhibited?)) - ("HoldoffTimeoutSec" (non-negative-integer elogind-holdoff-timeout-seconds)) - ("IdleAction" (handle-action elogind-idle-action)) - ("IdleActionSec" (non-negative-integer elogind-idle-action-seconds)) - ("RuntimeDirectorySize" - (identity - (lambda (config) - (match (elogind-runtime-directory-size-percent config) - (#f (non-negative-integer (elogind-runtime-directory-size config))) - (percent (string-append (non-negative-integer percent) "%")))))) - ("RemoveIPC" (yesno elogind-remove-ipc?)) - "[Sleep]" - ("SuspendState" (sleep-list elogind-suspend-state)) - ("SuspendMode" (sleep-list elogind-suspend-mode)) - ("HibernateState" (sleep-list elogind-hibernate-state)) - ("HibernateMode" (sleep-list elogind-hibernate-mode)) - ("HybridSleepState" (sleep-list elogind-hybrid-sleep-state)) - ("HybridSleepMode" (sleep-list elogind-hybrid-sleep-mode)) - ("HibernateDelaySec" (maybe-non-negative-integer elogind-hibernate-delay-seconds)) - ("SuspendEstimationSec" (maybe-non-negative-integer elogind-suspend-estimation-seconds)) - ("AllowPowerOffInterrupts" (yesno elogind-allow-power-off-interrupts?)) - ("AllowSuspendInterrupts" (yesno elogind-allow-suspend-interrupts?)) - ("BroadcastPowerOffInterrupts" (yesno elogind-broadcast-power-off-interrupts?)) - ("BroadcastSuspendInterrupts" (yesno elogind-broadcast-suspend-interrupts?)))) + `(("logind.conf.d/logind.conf" . + ,(ini-file + config "logind.conf" + "[Login]" + ("KillUserProcesses" (yesno elogind-kill-user-processes?)) + ("KillOnlyUsers" (user-name-list elogind-kill-only-users)) + ("KillExcludeUsers" (user-name-list elogind-kill-exclude-users)) + ("InhibitDelayMaxSec" (non-negative-integer elogind-inhibit-delay-max-seconds)) + ("HandlePowerKey" (handle-action elogind-handle-power-key)) + ("HandleSuspendKey" (handle-action elogind-handle-suspend-key)) + ("HandleHibernateKey" (handle-action elogind-handle-hibernate-key)) + ("HandleLidSwitch" (handle-action elogind-handle-lid-switch)) + ("HandleLidSwitchDocked" (handle-action elogind-handle-lid-switch-docked)) + ("HandleLidSwitchExternalPower" (handle-action elogind-handle-lid-switch-external-power)) + ("PowerKeyIgnoreInhibited" (yesno elogind-power-key-ignore-inhibited?)) + ("SuspendKeyIgnoreInhibited" (yesno elogind-suspend-key-ignore-inhibited?)) + ("HibernateKeyIgnoreInhibited" (yesno elogind-hibernate-key-ignore-inhibited?)) + ("LidSwitchIgnoreInhibited" (yesno elogind-lid-switch-ignore-inhibited?)) + ("HoldoffTimeoutSec" (non-negative-integer elogind-holdoff-timeout-seconds)) + ("IdleAction" (handle-action elogind-idle-action)) + ("IdleActionSec" (non-negative-integer elogind-idle-action-seconds)) + ("RuntimeDirectorySize" + (identity + (lambda (config) + (match (elogind-runtime-directory-size-percent config) + (#f (non-negative-integer (elogind-runtime-directory-size config))) + (percent (string-append (non-negative-integer percent) "%")))))) + ("RemoveIPC" (yesno elogind-remove-ipc?)))) + ("sleep.conf.d/sleep.conf" . + ,(ini-file + config "sleep.conf" + "[Sleep]" + ("SuspendState" (sleep-list elogind-suspend-state)) + ("SuspendMode" (sleep-list elogind-suspend-mode)) + ("HibernateState" (sleep-list elogind-hibernate-state)) + ("HibernateMode" (sleep-list elogind-hibernate-mode)) + ("HybridSleepState" (sleep-list elogind-hybrid-sleep-state)) + ("HybridSleepMode" (sleep-list elogind-hybrid-sleep-mode)) + ("HibernateDelaySec" (maybe-non-negative-integer elogind-hibernate-delay-seconds)) + ("SuspendEstimationSec" (maybe-non-negative-integer elogind-suspend-estimation-seconds)) + ("AllowPowerOffInterrupts" (yesno elogind-allow-power-off-interrupts?)) + ("AllowSuspendInterrupts" (yesno elogind-allow-suspend-interrupts?)) + ("BroadcastPowerOffInterrupts" (yesno elogind-broadcast-power-off-interrupts?)) + ("BroadcastSuspendInterrupts" (yesno elogind-broadcast-suspend-interrupts?)))))) (define (elogind-etc-directory config) "Return the /etc/elogind directory for CONFIG." - (with-imported-modules (source-module-closure '((guix build utils))) + (with-imported-modules (source-module-closure '((guix build utils) (ice-9 match) (srfi srfi-1))) (computed-file "etc-elogind" #~(begin - (use-modules (guix build utils)) + (use-modules (guix build utils) (ice-9 match) (srfi srfi-1)) (define sleep-directory (string-append #$output "/system-sleep/")) (define shutdown-directory (string-append #$output "/system-shutdown/")) @@ -1218,7 +1222,14 @@ (define (elogind-etc-directory config) '#$(elogind-system-sleep-hook-files config)) (for-each (lambda (f) (copy-script f shutdown-directory)) - '#$(elogind-system-shutdown-hook-files config)))))) + '#$(elogind-system-shutdown-hook-files config)) + #$@(append-map + (match-lambda + ((name . file) + (list + #~(mkdir-p (dirname (string-append #$output "/" #$name))) + #~(copy-file #$file (string-append #$output "/" #$name))))) + (elogind-configuration-files config)))))) (define (elogind-dbus-service config) "Return a @file{org.freedesktop.login1.service} file that tells D-Bus how to @@ -1301,20 +1312,13 @@ (define (pam-extension-procedure config) (define (elogind-shepherd-service config) "Return a Shepherd service to start elogind according to @var{config}." - (define config-file - (elogind-configuration-file config)) - (list (shepherd-service (requirement '(user-processes dbus-system)) (provision '(elogind)) (start #~(make-forkexec-constructor (list #$(file-append (elogind-package config) - "/libexec/elogind/elogind")) - #:environment-variables - (list (string-append "ELOGIND_CONF_FILE=" - #$config-file)))) - (stop #~(make-kill-destructor)) - (actions (list (shepherd-configuration-action config-file)))))) + "/libexec/elogind/elogind")))) + (stop #~(make-kill-destructor))))) (define elogind-service-type (service-type (name 'elogind) base-commit: a6c96cdb7060ccfc2d0fe27a45b9bcc9590aedd6 prerequisite-patch-id: 1ee329e14fdb8d1e35141e9b5972c5e9b8a2b252 -- 2.49.0 From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 24 17:39:38 2025 Received: (at 77806) by debbugs.gnu.org; 24 Apr 2025 21:39:38 +0000 Received: from localhost ([127.0.0.1]:42180 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u84IE-0006zb-Fd for submit@debbugs.gnu.org; Thu, 24 Apr 2025 17:39:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37912) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u84IB-0006ye-Nq for 77806@debbugs.gnu.org; Thu, 24 Apr 2025 17:39:36 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u84I5-0004Nr-H1; Thu, 24 Apr 2025 17:39:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=fONo9Pot1TW1BvOU8kXzIDUqvCHolN7tfmeFhoIsPb4=; b=VjM5nl76qFSpNcxpHEGf 8jNSBe4h35tk4c3lW03gPeuia4uiaLORmRqayM2gzcqMLzobVnuDfvSRZTNNU8dInGJ/b8oNKhc/K Ujywps2RYPn/j7nL1tcVUd5gvQne8MpthhD2oEWn1TsSKaH0KidaTfjPnD3j6wL1ghmpjiFqkPtDS shYZ0Ty1SnT+cMjf09vXP89ViZ7BGQzZhI0bdwbsyKZqblETNwOkGspvyifWV4U0tPaDfjpJUaFXO FSadrXYW5oPkdyHPhbK/VUNttT0Cc4IZiUo2W1bagmR1BnqkwJA9h7zUSunQeX2BaPzrrjBA20eQb xj4g3a7H19tm0w==; From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Josselin Poiret Subject: Re: [PATCH] gnu: elogind-service-type: Put user configuration in drop-in dirs. In-Reply-To: <3fc9c5b32e713320751ab52d90b3c66a37b025ec.1745490871.git.dev@jpoiret.xyz> (Josselin Poiret's message of "Thu, 24 Apr 2025 12:38:41 +0200") References: <87selyrutn.fsf@gmail.com> <3fc9c5b32e713320751ab52d90b3c66a37b025ec.1745490871.git.dev@jpoiret.xyz> User-Agent: mu4e 1.12.9; emacs 29.4 X-URL: https://people.bordeaux.inria.fr/lcourtes/ X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu X-Revolutionary-Date: Quintidi 5 =?utf-8?Q?Flor=C3=A9al?= an 233 de la =?utf-8?Q?R=C3=A9volution=2C?= jour du Rossignol Date: Thu, 24 Apr 2025 23:13:58 +0200 Message-ID: <87jz79i7op.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.3 (/) X-Debbugs-Envelope-To: 77806 Cc: Bas Alberts , Maxim Cournoyer , 77806@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.3 (-) Hey, Josselin Poiret writes: > From: Josselin Poiret > > * gnu/services/desktop.scm (elogind-configuration-files): Renamed from > elogind-configuration-file. Split sections [Login] and [Sleep] in two fil= es. > (elogind-shepherd-service): Remove useless environment variable. > > Change-Id: Ibb4db04152c397c1ed4a35118129a2860ac9c2b5 > + `(("logind.conf.d/logind.conf" . [...] > + ("sleep.conf.d/sleep.conf" . Should it be elogind/{logind.conf,sleep.conf}? > (define (elogind-etc-directory config) > "Return the /etc/elogind directory for CONFIG." > - (with-imported-modules (source-module-closure '((guix build utils))) > + (with-imported-modules (source-module-closure '((guix build utils) (ic= e-9 match) (srfi srfi-1))) This is incorrect: it would import these two modules from the host Guile into the build environment. > + #$@(append-map > + (match-lambda > + ((name . file) > + (list > + #~(mkdir-p (dirname (string-append #$output "/" #$name)= )) > + #~(copy-file #$file (string-append #$output "/" #$name)= )))) > + (elogind-configuration-files config)))))) I=E2=80=99d rather avoid the list of gexps and instead write: #$(map (match-lambda ((target . file) #~(begin (mkdir-p =E2=80=A6) (copy-file =E2=80=A6)))) =E2=80=A6) > - (actions (list (shepherd-configuration-action config-file)))))) Too bad we=E2=80=99re losing this. Perhaps we could have a custom =E2=80=98configuration=E2=80=99 action returning the list of config files? Not a blocker anyway. Thanks for fixing it, I=E2=80=99ve inadvertently turned off my laptop too m= any times! Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 24 22:11:13 2025 Received: (at 77806) by debbugs.gnu.org; 25 Apr 2025 02:11:13 +0000 Received: from localhost ([127.0.0.1]:43676 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u88X0-0000J2-Jm for submit@debbugs.gnu.org; Thu, 24 Apr 2025 22:11:13 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]:59712) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1u88Wf-0000Eg-8E for 77806@debbugs.gnu.org; Thu, 24 Apr 2025 22:11:06 -0400 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-7376e311086so2226874b3a.3 for <77806@debbugs.gnu.org>; Thu, 24 Apr 2025 19:10:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745547042; x=1746151842; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=6mwGpQFwG48k+sM+AFqTuttRcpbI1NjdCnip0/p7uDY=; b=PXdN04X1pL4EY0lL/2+61YzlnEGwW6AEDWloQILNrVUe1WMeChK90q3TLdsbw7J2mN 91BKkcCSlQNuND/6AU/hG5S8+bz31wOcB5XMD2NlNs0cF7LFmHEitJLXQr23rnwfATUf oyMfKwiQSrlfY6qZrqi3nedIgYHHHSBhIUIPQFGFWlIn5j25ezdeprP8esoklrSUSt94 Ja0Fq8jlr5Vaf/LGqvCJR2QxgTqtGTOg6HDyI6a2LJXJSyZ0HL8Spu0JbOATYtYArkqK 1VLf+zm3EqxYiGx7qYXYRZKyGTAZMXC3fy/87ZEjLVLHmMdd3omLODYiMmzBQisaE2D/ 6z9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745547042; x=1746151842; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=6mwGpQFwG48k+sM+AFqTuttRcpbI1NjdCnip0/p7uDY=; b=j/GY+rRRaBYq+CX5GA8GjGe5hgTYtic9ZD+AQxuknCflairVNDAh/eCBiiJGtM194b nejBLK/eSKAI06eFkHKqJ1T1pGDx6Zynzp+25am7dmR5DZcUQ0DE1ac4jNW9c6VO4usy rBSBsl5UiBEYCJid/YLuYtrdHgCEwuhumj00eGNdNp6OZzYVNn9Sdk8kyH2Y/JvoQSL6 ChkvBrb0LeosGy6NLje5gnxEeQWaSZ5CkCpR0iuZ6qQp7xbHszSOQGHBEAefbynXTZ3o erJbx4VXnzlsrxa/qxf5XMrfSrMqxrq9k/cGHgO2ImNvOh6im6p9CiHqojlBM5WcJ/3W dksQ== X-Gm-Message-State: AOJu0Yw0uKpqJc2UQWRYwv6Rr8AJWvctyd6VE19S3dPhSYLOzKEcwpGl mibjwbrz8OkbxRLxiOrCliZuNLiFzb+/AICjIOwIaQOKZOTEXfysHZWB3Q== X-Gm-Gg: ASbGncsanGjnBIUa/ObEacw9ei4vaSWNsCFdFDPpIQBBZFienE1watrLpFRHoNs4dui /myYRJ80b5fNrkSZB9IhcMk/mkArF/OD9NlY9NcxLNaVPlEVOjuDqJeUhp4egylxMzTDx8Lainn g8KV5NVSzcwxSZi6EghijCjB37pK//BBtFVEXktSR6i7E1TKonC7W4ybGykPPbgMDEFnNpgn6wz 5qf5il97HzDh68Gh9nuno8NwMC0trsejDwZGoUbSpen5Dykp2SN1zPr+7nWrnWXHox1bK073Led 8K+jrHBm/ZUi3y7rEkfDBlbR6iuMMWurelym0tjckNEISCpzxP7jz7b5Q8mq X-Google-Smtp-Source: AGHT+IGBLPU/9iG9Zmpwn0HPBR/l/Rx3GsPK87r/QipnK5GyGoI1K0epb7Q98vrdJHYBMBg/fQIXJA== X-Received: by 2002:a05:6a00:1390:b0:737:678d:fb66 with SMTP id d2e1a72fcca58-73fd680d337mr625082b3a.5.1745547041666; Thu, 24 Apr 2025 19:10:41 -0700 (PDT) Received: from localhost.localdomain ([2405:6586:be0:0:83c8:d31d:2cec:f542]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73e25965823sm2124321b3a.78.2025.04.24.19.10.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Apr 2025 19:10:40 -0700 (PDT) From: Maxim Cournoyer To: 77806@debbugs.gnu.org Subject: [PATCH v2] services: elogind: Split sleep.conf and port to define-configuration. Date: Fri, 25 Apr 2025 11:10:16 +0900 Message-ID: <53ef49b7a94e50b4be97d0696d499e1f3d776898.1745547016.git.maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.49.0 MIME-Version: 1.0 X-Debbugs-Cc: Ludovic Courtès , Bas Alberts , Maxim Cournoyer , Josselin Poiret , Liliana Marie Prikler , Noé Lopez , Vivien Kraus Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 77806 Cc: Maxim Cournoyer X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * gnu/services/desktop.scm (pascal-case): New procedure. (): Rewrite in terms of define-configuration. (elogind-configuration-file): Delete. (maybe-list-of-suspend-states?, maybe-list-of-suspend-modes?) maybe-list-of-user-names?, maybe-boolean?maybe-package?) (maybe-action?, maybe-percent?, maybe-list-of-strings?) (maybe-list-of-hibernation-modes?, maybe-non-negative-integer?) (non-negative-integer?, percent?, char-set:user-name, user-name?) (list-of-user-names?, %elogind-actions, action?, %linux-suspend-states) (string->symbol/maybe, suspend-state?, list-of-suspend-states?) (%linux-suspend-modes, suspend-mode?, list-of-suspend-modes?) (%linux-hibernation-modes, hibernation-mode?, list-of-hibernation-modes?) (elogind-deprecated-empty-serializer, list-of-file-likes?) (elogind-serialize-boolean, elogind-base-serializer, elogind-serialize-action) (elogind-serialize-non-negative-integer, elogind-serialize-percent) (elogind-list-serializer, elogind-serialize-list-of-strings) (elogind-serialize-list-of-user-names, elogind-serialize-list-of-suspend-states) (elogind-serialize-list-of-suspend-modes) (elogind-serialize-list-of-hibernation-modes) (%elogind-configuration-sleep-fields, logind.conf, sleep.conf): New procedures. (elogind-etc-directory): Create the main configuration files there too. (elogind-dbus-service): Adjust for package accessor name change. (pam-extension-procedure, elogind-shepherd-service) (elogind-service-type): Likewise. * doc/guix.texi (Desktop Services): Fully document configuration options. Fixes: bug#77806 Change-Id: I8767891871d83e58d64995ec986a7d01689fa6d8 --- doc/guix.texi | 191 +++++++----- gnu/services/desktop.scm | 628 ++++++++++++++++++++++++++------------- 2 files changed, 524 insertions(+), 295 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index be2fbbaf5bc..7b418a40892 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -26264,129 +26264,158 @@ Desktop Services @code{} object. @end defvar -@c TODO: field descriptions. This is best done by refactoring -@c elogind-configuration to use define-configuration which embeds the -@c descriptions in the code and then use configuration->documentation. +@c Auto-generated via (configuration->documentation 'elogind-configuration). +@c %start of fragment + @deftp {Data Type} elogind-configuration -Data type representing the configuration of @command{elogind}. +Available @code{elogind-configuration} fields are: @table @asis @item @code{elogind} (default: @code{elogind}) (type: file-like) -... +The elogind package to use. -@item @code{kill-user-processes?} (default: @code{#f}) (type: boolean) -... +@item @code{system-sleep-hook-files} (default: @code{()}) (type: list-of-file-likes) +A list of executables (file-like objects) that will be installed into +the @file{/etc/elogind/system-sleep} hook directory. See `Hook +directories' in the @samp{loginctl(1)} man page for more information. -@item @code{kill-only-users} (default: @code{'()}) (type: list) -... +@item @code{system-shutdown-hook-files} (default: @code{()}) (type: list-of-file-likes) +A list of executables (file-like objects) that will be installed into +the @file{/etc/elogind/system-shutdown/} hook directory. -@item @code{kill-exclude-users} (default: @code{'("root")}) (type: list-of-string) -... +@item @code{allow-power-off-interrupts?} (default: @code{#f}) (type: maybe-boolean) +Whether the executables in elogind's hook directories (see above) can +cause a power-off action to be cancelled (interrupted) by printing an +appropriate error message to stdout. -@item @code{inhibit-delay-max-seconds} (default: @code{5}) (type: integer) -... +@item @code{allow-suspend-interrupts?} (default: @code{#f}) (type: maybe-boolean) +Likewise as the @code{allow-power-off-interrupts?} option, but for the +suspend action. -@item @code{handle-power-key} (default: @code{'poweroff}) (type: symbol) -... +@item @code{broadcast-power-off-interrupts?} (default: @code{#f}) (type: maybe-boolean) +Whether an interrupt of a power-off action is broadcasted. -@item @code{handle-suspend-key} (default: @code{'suspend}) (type: symbol) -... +@item @code{broadcast-suspend-interrupts?} (default: @code{#f}) (type: maybe-boolean) +Whether an interrupt of a suspend action is broadcasted. -@item @code{handle-hibernate-key} (default: @code{'hibernate}) (type: symbol) -... +@item @code{kill-user-processes?} (default: @code{#f}) (type: maybe-boolean) +Whether the processes of a user should be killed when the user logs out. -@item @code{handle-lid-switch} (default: @code{'suspend}) (type: symbol) -... +@item @code{kill-only-users} (type: maybe-list-of-user-names) +Usernames whose processes should be killed, regardless the value of +@code{kill-user-processes?}. -@item @code{handle-lid-switch-docked} (default: @code{'ignore}) (type: symbol) -... +@item @code{kill-exclude-users} (default: @code{("root")}) (type: maybe-list-of-user-names) +Usernames whose processes should @emph{not} be killed, regardless the +value of @code{kill-user-processes?}. -@item @code{handle-lid-switch-external-power} (default: @code{*unspecified*}) (type: symbol) -... +@item @code{inhibit-delay-max-seconds} (default: @code{5}) (type: maybe-non-negative-integer) +The maximum time a system shutdown or sleep request is delayed due to an +inhibitor lock of type delay being active before the inhibitor is +ignored and the operation executes anyway. -@item @code{power-key-ignore-inhibited?} (default: @code{#f}) (type: boolean) -... +@item @code{handle-power-key} (default: @code{poweroff}) (type: maybe-action) +The action done when the power key is pressed. The compiled default is +@code{'poweroff}. -@item @code{suspend-key-ignore-inhibited?} (default: @code{#f}) (type: boolean) -... +@item @code{handle-suspend-key} (default: @code{suspend}) (type: maybe-action) +The action done when the suspend key is pressed. The -@item @code{hibernate-key-ignore-inhibited?} (default: @code{#f}) (type: boolean) -... +@item @code{handle-hibernate-key} (default: @code{hibernate}) (type: maybe-action) +The action done when the hibernate key is pressed. -@item @code{lid-switch-ignore-inhibited?} (default: @code{#t}) (type: boolean) -... +@item @code{handle-lid-switch} (default: @code{suspend}) (type: maybe-action) +The action done when the lid is closed. -@item @code{holdoff-timeout-seconds} (default: @code{30}) (type: integer) -... +@item @code{handle-lid-switch-docked} (default: @code{ignore}) (type: maybe-action) +The action done when the lid is closed and the device docked. -@item @code{idle-action} (default: @code{'ignore}) (type: symbol) -... +@item @code{handle-lid-switch-external-power} (default: @code{suspend}) (type: maybe-action) +The action done when the lid is closed and the device is externally +powered. -@item @code{idle-action-seconds} (default: @code{(* 30 60)}) (type: integer) -... +@item @code{power-key-ignore-inhibited?} (default: @code{#f}) (type: maybe-boolean) +Whether to ignore high-level inhibitor locks (shutdown, reboot, sleep or +idle) when the power key is pressed. -@item @code{runtime-directory-size-percent} (default: @code{10}) (type: integer) -... +@item @code{suspend-key-ignore-inhibited?} (default: @code{#f}) (type: maybe-boolean) +Whether to ignore high-level inhibitor locks (shutdown, reboot, sleep or +idle) when the suspend key is pressed. -@item @code{runtime-directory-size} (default: @code{#f}) (type: integer) -... +@item @code{hibernate-key-ignore-inhibited?} (default: @code{#f}) (type: maybe-boolean) +Whether to ignore high-level inhibitor locks (shutdown, reboot, sleep or +idle) when the hibernate key is pressed. -@item @code{remove-ipc?} (default: @code{#t}) (type: boolean) -... +@item @code{lid-switch-ignore-inhibited?} (default: @code{#f}) (type: maybe-boolean) +Whether to ignore high-level inhibitor locks (shutdown, reboot, sleep or +idle) when the lid is closed. -@item @code{suspend-state} (default: @code{'("mem" "standby" "freeze")}) (type: list) -... +@item @code{holdoff-timeout-seconds} (default: @code{30}) (type: maybe-non-negative-integer) +Specifies the number of seconds after system startup or system resume +during which elogind will hold off on reacting to lid events. -@item @code{suspend-mode} (default: @code{'()}) (type: list) -... +@item @code{idle-action} (default: @code{ignore}) (type: maybe-action) +Action to take when the system is idle. -@item @code{hibernate-state} (default: @code{'("disk")}) (type: list) -... +@item @code{idle-action-seconds} (type: maybe-non-negative-integer) +The delay after which the action configured in @code{idle-action} is +taken after the system is idle. -@item @code{hibernate-mode} (default: @code{'("platform" "shutdown")}) (type: list) -... +@item @code{runtime-directory-size-percent} (type: maybe-percent) +Set the size limit, in percent, on the @env{XDG_RUNTIME_DIR} runtime +directory for each user who logs in. This specifies the per-user size +limit relative to the amount of physical @acronym{RAM,read access +memory}. This value takes precedence over that specified via +@code{runtime-directory-size}. -@item @code{hybrid-sleep-state} (default: @code{'("disk")}) (type: list) -... +@item @code{runtime-directory-size} (type: maybe-non-negative-integer) +Set the size limit, in bytes, on the @env{XDG_RUNTIME_DIR} runtime +directory for each user who logs in. -@item @code{hybrid-sleep-mode} (default: @code{'("suspend" "platform" "shutdown")}) (type: list) -... +@item @code{remove-ipc?} (default: @code{#t}) (type: maybe-boolean) +Whether @acronym{IPC,inter-process communication} objects belonging to +the user shall be removed when the user fully logs out. -@item @code{hibernate-delay-seconds} (default: @code{*unspecified*}) (type: integer) -... +@item @code{suspend-state} (default: @code{(mem standby freeze)}) (type: maybe-list-of-suspend-states) +The suspend state values to be write to @file{/sys/power/state} by +elogind when suspending the system. They will be tried in turn, until +one is written without error. -@item @code{suspend-estimation-seconds} (default: @code{*unspecified*}) (type: integer) -... +@item @code{suspend-mode} (type: maybe-list-of-suspend-modes) +The suspend mode values to write to @file{/sys/power/mem_sleep} by +elogind when suspending the system. -@item @code{system-sleep-hook-files} (default: @code{'()}) (type: list) -A list of executables (file-like objects) that will be installed into -the @file{/etc/elogind/system-sleep/} hook directory. For example: +@item @code{suspend-estimation-seconds} (default: @code{3600}) (type: maybe-non-negative-integer) +Cause the RTC alarm to wake the system after the specified time span to +measure the system battery capacity level and estimate the battery +discharging rate, which is used for estimating the time span until the +system battery charge level goes down to 5%. This option is only used +by elogind when using the @code{'suspend-then-hibernate} action. -@lisp -(elogind-configuration - (system-sleep-hook-files - (list (local-file "sleep-script")))) -@end lisp +@item @code{hibernate-mode} (default: @code{(platform shutdown)}) (type: maybe-list-of-hibernation-modes) +The hibernation mode values to write to @file{/sys/power/disk} by +elogind when hibernating the system. -See `Hook directories' in the @code{loginctl(1)} man page for more information. +@item @code{hibernate-delay-seconds} (type: maybe-non-negative-integer) +The amount of time the system spends in suspend mode before the system +is automatically put into hibernate mode. -@item @code{system-shutdown-hook-files} (default: @code{'()}) (type: list) -A list of executables (file-like objects) that will be installed into -the @file{/etc/elogind/system-shutdown/} hook directory. +@item @code{hibernate-state} (type: maybe-list-of-strings) +Deprecated option. -@item @code{allow-power-off-interrupts?} (default: @code{#f}) (type: boolean) -@itemx @code{allow-suspend-interrupts?} (default: @code{#f}) (type: boolean) -Whether the executables in elogind's hook directories (see above) can -cause a power-off or suspend action to be cancelled (interrupted) by -printing an appropriate error message to stdout. +@item @code{hybrid-sleep-state} (type: maybe-list-of-strings) +Deprecated option. -@item @code{broadcast-power-off-interrupts?} (default: @code{#t}) (type: boolean) -@itemx @code{broadcast-suspend-interrupts?} (default: @code{#t}) (type: boolean) -Whether an interrupt of a power-off or suspend action is broadcasted. +@item @code{hybrid-sleep-mode} (type: maybe-list-of-strings) +Deprecated option. @end table + @end deftp + +@c %end of fragment + @defvar accountsservice-service-type Type for the service that runs AccountsService, a system service that can list available accounts, change their passwords, and so on. diff --git a/gnu/services/desktop.scm b/gnu/services/desktop.scm index fe034cfa8f4..e422fbc89df 100644 --- a/gnu/services/desktop.scm +++ b/gnu/services/desktop.scm @@ -37,6 +37,7 @@ ;;; along with GNU Guix. If not, see . (define-module (gnu services desktop) + #:use-module ((gnu home services utils) #:select (object->camel-case-string)) #:use-module (gnu services) #:use-module (gnu services shepherd) #:use-module (gnu services base) @@ -228,6 +229,8 @@ (define (package-direct-input-selector tree) (loop (cdr tree) (car (assoc-ref (package-direct-inputs package) (car tree)))))))) +(define (pascal-case text) + (object->camel-case-string text 'upper)) ;;; @@ -1025,173 +1028,367 @@ (define gvfs-service-type ;;; Elogind login and seat management service. ;;; -(define-record-type* elogind-configuration - make-elogind-configuration - elogind-configuration? - (elogind elogind-package - (default elogind)) - (kill-user-processes? elogind-kill-user-processes? - (default #f)) - (kill-only-users elogind-kill-only-users - (default '())) - (kill-exclude-users elogind-kill-exclude-users - (default '("root"))) - (inhibit-delay-max-seconds elogind-inhibit-delay-max-seconds - (default 5)) - (handle-power-key elogind-handle-power-key - (default 'poweroff)) - (handle-suspend-key elogind-handle-suspend-key - (default 'suspend)) - (handle-hibernate-key elogind-handle-hibernate-key - (default 'hibernate)) - (handle-lid-switch elogind-handle-lid-switch - (default 'suspend)) - (handle-lid-switch-docked elogind-handle-lid-switch-docked - (default 'ignore)) - (handle-lid-switch-external-power elogind-handle-lid-switch-external-power - (default *unspecified*)) - (power-key-ignore-inhibited? elogind-power-key-ignore-inhibited? - (default #f)) - (suspend-key-ignore-inhibited? elogind-suspend-key-ignore-inhibited? - (default #f)) - (hibernate-key-ignore-inhibited? elogind-hibernate-key-ignore-inhibited? - (default #f)) - (lid-switch-ignore-inhibited? elogind-lid-switch-ignore-inhibited? - (default #t)) - (holdoff-timeout-seconds elogind-holdoff-timeout-seconds - (default 30)) - (idle-action elogind-idle-action - (default 'ignore)) - (idle-action-seconds elogind-idle-action-seconds - (default (* 30 60))) - (runtime-directory-size-percent elogind-runtime-directory-size-percent - (default 10)) - (runtime-directory-size elogind-runtime-directory-size - (default #f)) - (remove-ipc? elogind-remove-ipc? - (default #t)) - - (suspend-state elogind-suspend-state - (default '("mem" "standby" "freeze"))) - (suspend-mode elogind-suspend-mode - (default '())) - (hibernate-state elogind-hibernate-state - (default '("disk"))) - (hibernate-mode elogind-hibernate-mode - (default '("platform" "shutdown"))) - (hybrid-sleep-state elogind-hybrid-sleep-state - (default '("disk"))) - (hybrid-sleep-mode elogind-hybrid-sleep-mode - (default - '("suspend" "platform" "shutdown"))) - (hibernate-delay-seconds elogind-hibernate-delay-seconds - (default *unspecified*)) - (suspend-estimation-seconds elogind-suspend-estimation-seconds - (default *unspecified*)) - (system-sleep-hook-files elogind-system-sleep-hook-files - (default '())) - (system-shutdown-hook-files elogind-system-shutdown-hook-files - (default '())) - (allow-power-off-interrupts? elogind-allow-power-off-interrupts? - (default #f)) - (allow-suspend-interrupts? elogind-allow-suspend-interrupts? - (default #f)) - (broadcast-power-off-interrupts? elogind-broadcast-power-off-interrupts? - (default #t)) - (broadcast-suspend-interrupts? elogind-broadcast-suspend-interrupts? - (default #t))) - -(define (elogind-configuration-file config) - (define (yesno x) - (match x - (#t "yes") - (#f "no") - (_ (error "expected #t or #f, instead got:" x)))) - (define char-set:user-name - (string->char-set "abcdefghijklmnopqrstuvwxyz0123456789_-")) - (define (valid-list? l pred) - (and-map (lambda (x) (string-every pred x)) l)) - (define (user-name-list users) - (unless (valid-list? users char-set:user-name) - (error "invalid user list" users)) - (string-join users " ")) - (define (enum val allowed) - (unless (memq val allowed) - (error "invalid value" val allowed)) - (symbol->string val)) - (define (non-negative-integer x) - (unless (exact-integer? x) (error "not an integer" x)) - (when (negative? x) (error "negative number not allowed" x)) - (number->string x)) - (define (maybe-non-negative-integer x) - (or (and (unspecified? x) x) - (non-negative-integer x))) - (define handle-actions - '(ignore poweroff reboot halt kexec suspend hibernate hybrid-sleep suspend-then-hibernate lock)) - (define (handle-action x) - (if (unspecified? x) - x ;let the unspecified value go through - (enum x handle-actions))) - (define (sleep-list tokens) - (unless (valid-list? tokens char-set:user-name) - (error "invalid sleep list" tokens)) - (string-join tokens " ")) - (define-syntax ini-file-clause - (syntax-rules () - ;; Produce an empty line when encountering an unspecified value. This - ;; is better than an empty string value, which can, in some cases, cause - ;; warnings such as "Failed to parse handle action setting". - ((_ config (prop (parser getter))) - (let ((value (parser (getter config)))) - (if (unspecified? value) - "" - (string-append prop "=" value "\n")))) - ((_ config str) - (if (unspecified? str) - "" - (string-append str "\n"))))) - (define-syntax-rule (ini-file config file clause ...) - (plain-file file (string-append (ini-file-clause config clause) ...))) - (ini-file - config "logind.conf" - "[Login]" - ("KillUserProcesses" (yesno elogind-kill-user-processes?)) - ("KillOnlyUsers" (user-name-list elogind-kill-only-users)) - ("KillExcludeUsers" (user-name-list elogind-kill-exclude-users)) - ("InhibitDelayMaxSec" (non-negative-integer elogind-inhibit-delay-max-seconds)) - ("HandlePowerKey" (handle-action elogind-handle-power-key)) - ("HandleSuspendKey" (handle-action elogind-handle-suspend-key)) - ("HandleHibernateKey" (handle-action elogind-handle-hibernate-key)) - ("HandleLidSwitch" (handle-action elogind-handle-lid-switch)) - ("HandleLidSwitchDocked" (handle-action elogind-handle-lid-switch-docked)) - ("HandleLidSwitchExternalPower" (handle-action elogind-handle-lid-switch-external-power)) - ("PowerKeyIgnoreInhibited" (yesno elogind-power-key-ignore-inhibited?)) - ("SuspendKeyIgnoreInhibited" (yesno elogind-suspend-key-ignore-inhibited?)) - ("HibernateKeyIgnoreInhibited" (yesno elogind-hibernate-key-ignore-inhibited?)) - ("LidSwitchIgnoreInhibited" (yesno elogind-lid-switch-ignore-inhibited?)) - ("HoldoffTimeoutSec" (non-negative-integer elogind-holdoff-timeout-seconds)) - ("IdleAction" (handle-action elogind-idle-action)) - ("IdleActionSec" (non-negative-integer elogind-idle-action-seconds)) - ("RuntimeDirectorySize" - (identity - (lambda (config) - (match (elogind-runtime-directory-size-percent config) - (#f (non-negative-integer (elogind-runtime-directory-size config))) - (percent (string-append (non-negative-integer percent) "%")))))) - ("RemoveIPC" (yesno elogind-remove-ipc?)) - "[Sleep]" - ("SuspendState" (sleep-list elogind-suspend-state)) - ("SuspendMode" (sleep-list elogind-suspend-mode)) - ("HibernateState" (sleep-list elogind-hibernate-state)) - ("HibernateMode" (sleep-list elogind-hibernate-mode)) - ("HybridSleepState" (sleep-list elogind-hybrid-sleep-state)) - ("HybridSleepMode" (sleep-list elogind-hybrid-sleep-mode)) - ("HibernateDelaySec" (maybe-non-negative-integer elogind-hibernate-delay-seconds)) - ("SuspendEstimationSec" (maybe-non-negative-integer elogind-suspend-estimation-seconds)) - ("AllowPowerOffInterrupts" (yesno elogind-allow-power-off-interrupts?)) - ("AllowSuspendInterrupts" (yesno elogind-allow-suspend-interrupts?)) - ("BroadcastPowerOffInterrupts" (yesno elogind-broadcast-power-off-interrupts?)) - ("BroadcastSuspendInterrupts" (yesno elogind-broadcast-suspend-interrupts?)))) +;;; Elogind configuration types. +(define-maybe boolean + (prefix elogind-)) + +(define (non-negative-integer? x) + (and (exact-integer? x) + (not (negative? x)))) + +(define-maybe non-negative-integer + (prefix elogind-)) + +(define (percent? x) + (and (non-negative-integer? x) + (>= x 0) + (<= x 100))) + +(define-maybe percent + (prefix elogind-)) + +(define char-set:user-name + (string->char-set "abcdefghijklmnopqrstuvwxyz0123456789_-")) + +(define (user-name? x) + (string-every char-set:user-name x)) + +(define list-of-user-names? + (list-of user-name?)) + +(define-maybe list-of-user-names + (prefix elogind-)) + +(define %elogind-actions + '( ignore poweroff reboot halt kexec suspend hibernate hybrid-sleep + suspend-then-hibernate lock factory-reset)) + +(define (action? x) + (member x %elogind-actions)) + +(define-maybe action + (prefix elogind-)) + +(define %linux-suspend-states + ;; The possible suspend states supported by the Linux kernel. + ;; See (info "(linux) Basic sysfs Interfaces for System Suspend and Hibernation"). + '(disk standby freeze mem)) + +(define (string->symbol/maybe x) + (if (string? x) + (string->symbol x) + x)) + +(define (suspend-state? x) + (member (string->symbol/maybe x) %linux-suspend-states)) + +(define list-of-suspend-states? + (list-of suspend-state?)) + +(define-maybe list-of-suspend-states + (prefix elogind-)) + +(define %linux-suspend-modes + ;; The possible suspend state variants supported by the Linux kernel. + ;; See (info "(linux) Basic sysfs Interfaces for System Suspend and Hibernation"). + '(s2idle shallow deep)) + +(define (suspend-mode? x) + (member (string->symbol/maybe x) %linux-suspend-modes)) + +(define list-of-suspend-modes? + (list-of suspend-mode?)) + +(define-maybe list-of-suspend-modes + (prefix elogind-)) + +(define %linux-hibernation-modes + ;; The possible hibernation operating modes supported by the Linux kernel. + ;; See (info "(linux) Basic sysfs Interfaces for System Suspend and Hibernation"). + '(platform shutdown reboot suspend test_resume)) + +(define (hibernation-mode? x) + (member (string->symbol/maybe x) %linux-hibernation-modes)) + +(define list-of-hibernation-modes? + (list-of hibernation-mode?)) + +(define-maybe list-of-hibernation-modes + (prefix elogind-)) + +(define (elogind-deprecated-empty-serializer name value) + (when (maybe-value-set? value) + (warn-about-deprecation name #f + #:replacement #f)) + "") + +(define list-of-file-likes? + (list-of file-like?)) + +(define-maybe list-of-strings + (prefix elogind-)) + +;;; Elogind serializers. +(define (elogind-serialize-boolean name value) + (let* ((name-str (symbol->string name)) + (name (if (string-suffix? "?" name-str) + (string-drop-right name-str 1) + name-str))) + (format #f "~a=~:[no~;yes~]~%" (pascal-case name) value))) + +(define (elogind-base-serializer name value) + (let* ((name-str (symbol->string name)) + (name (if (string-suffix? "seconds" name-str) + (string-drop-right name-str 4) ;seconds -> sec + name-str))) + (format #f "~a=~a~%" (pascal-case name) value))) + +(define elogind-serialize-action elogind-base-serializer) +(define elogind-serialize-non-negative-integer elogind-base-serializer) +(define elogind-serialize-percent elogind-base-serializer) + +(define (elogind-list-serializer name value) + (format #f "~a=~{~a~^ ~}~%" (pascal-case name) value)) + +(define elogind-serialize-list-of-strings elogind-list-serializer) +(define elogind-serialize-list-of-user-names elogind-list-serializer) +(define elogind-serialize-list-of-suspend-states elogind-list-serializer) +(define elogind-serialize-list-of-suspend-modes elogind-list-serializer) +(define elogind-serialize-list-of-hibernation-modes elogind-list-serializer) + +;;; XXX: For backward-compatible/historical reasons, the configuration object +;;; is flat, containing the fields of both the logind.conf and sleep.conf +;;; files. The list below contains the fields that should be serialized to +;;; sleep.conf. +(define %elogind-configuration-sleep-fields + '( suspend-state suspend-mode suspend-estimation-seconds + hibernate-mode hibernate-delay-seconds hibernate-state + hybrid-sleep-state hybrid-sleep-mode)) + +(define-configuration elogind-configuration + (elogind + (file-like elogind) + "The elogind package to use." + (serializer empty-serializer)) + + (system-sleep-hook-files + (list-of-file-likes '()) + "A list of executables (file-like objects) that will be installed into the +@file{/etc/elogind/system-sleep} hook directory. See `Hook directories' in +the @samp{loginctl(1)} man page for more information." + (serializer empty-serializer)) + + (system-shutdown-hook-files + (list-of-file-likes '()) + "A list of executables (file-like objects) that will be installed into the +@file{/etc/elogind/system-shutdown/} hook directory." + (serializer empty-serializer)) + + (allow-power-off-interrupts? + (maybe-boolean #f) + "Whether the executables in elogind's hook directories (see above) can + cause a power-off action to be cancelled (interrupted) by printing an + appropriate error message to stdout.") + + (allow-suspend-interrupts? + (maybe-boolean #f) + "Likewise as the @code{allow-power-off-interrupts?} option, but for the + suspend action.") + + (broadcast-power-off-interrupts? + (maybe-boolean #f) + "Whether an interrupt of a power-off action is broadcasted.") + + (broadcast-suspend-interrupts? + (maybe-boolean #f) + "Whether an interrupt of a suspend action is broadcasted.") + + ;; logind.conf options. + (kill-user-processes? + (maybe-boolean #f) + "Whether the processes of a user should be killed when the user logs + out.") + + (kill-only-users + maybe-list-of-user-names + "Usernames whose processes should be killed, regardless the value of + @code{kill-user-processes?}.") + + (kill-exclude-users + (maybe-list-of-user-names (list "root")) + "Usernames whose processes should @emph{not} be killed, regardless the + value of @code{kill-user-processes?}.") + + (inhibit-delay-max-seconds + (maybe-non-negative-integer 5) + "The maximum time a system shutdown or sleep request is delayed due to an + inhibitor lock of type delay being active before the inhibitor is ignored and + the operation executes anyway.") + + (handle-power-key + (maybe-action 'poweroff) + "The action done when the power key is pressed. The compiled default is + @code{'poweroff}.") + + (handle-suspend-key + (maybe-action 'suspend) + "The action done when the suspend key is pressed. The ") + + (handle-hibernate-key + (maybe-action 'hibernate) + "The action done when the hibernate key is pressed.") + + (handle-lid-switch + (maybe-action 'suspend) + "The action done when the lid is closed.") + + (handle-lid-switch-docked + (maybe-action 'ignore) + "The action done when the lid is closed and the device docked.") + + (handle-lid-switch-external-power + (maybe-action 'suspend) + "The action done when the lid is closed and the device is externally + powered.") + + (power-key-ignore-inhibited? + (maybe-boolean #f) + "Whether to ignore high-level inhibitor locks (shutdown, reboot, sleep or + idle) when the power key is pressed.") + + (suspend-key-ignore-inhibited? + (maybe-boolean #f) + "Whether to ignore high-level inhibitor locks (shutdown, reboot, sleep or + idle) when the suspend key is pressed.") + + (hibernate-key-ignore-inhibited? + (maybe-boolean #f) + "Whether to ignore high-level inhibitor locks (shutdown, reboot, sleep or + idle) when the hibernate key is pressed.") + + (lid-switch-ignore-inhibited? + (maybe-boolean #f) + "Whether to ignore high-level inhibitor locks (shutdown, reboot, sleep or + idle) when the lid is closed.") + + (holdoff-timeout-seconds + (maybe-non-negative-integer 30) + "Specifies the number of seconds after system startup or system resume +during which elogind will hold off on reacting to lid events.") + + (idle-action + (maybe-action 'ignore) + "Action to take when the system is idle.") + + (idle-action-seconds + maybe-non-negative-integer + "The delay after which the action configured in @code{idle-action} is +taken after the system is idle.") + + ;; XXX: Perhaps deprecate in the future and handle all the accepted forms + ;; directly in 'runtime-directory-size' instead. + (runtime-directory-size-percent + maybe-percent + "Set the size limit, in percent, on the @env{XDG_RUNTIME_DIR} runtime +directory for each user who logs in. This specifies the per-user size limit +relative to the amount of physical @acronym{RAM, read access memory}. This +value takes precedence over that specified via @code{runtime-directory-size}." + (serializer empty-serializer)) ;special cased at serialization time + + (runtime-directory-size + maybe-non-negative-integer + "Set the size limit, in bytes, on the @env{XDG_RUNTIME_DIR} runtime +directory for each user who logs in." + (serializer empty-serializer)) ;special cased at serialization time + + (remove-ipc? + (maybe-boolean #t) + "Whether @acronym{IPC, inter-process communication} objects belonging to +the user shall be removed when the user fully logs out.") + + ;; sleep.conf options. + ;; CAUTION: all sleep.conf option names must be registered in the above + ;; %ELOGIND-CONFIGURATION-SLEEP-FIELDS variable: otherwise they will be + ;; serialized to logind.conf instead of sleep.conf! + (suspend-state + (maybe-list-of-suspend-states '(mem standby freeze)) + "The suspend state values to be write to @file{/sys/power/state} by elogind + when suspending the system. They will be tried in turn, until one is written + without error.") + + (suspend-mode + (maybe-list-of-suspend-modes) + "The suspend mode values to write to @file{/sys/power/mem_sleep} by elogind + when suspending the system.") + + (suspend-estimation-seconds + (maybe-non-negative-integer (* 60 60)) ;1 hour + "Cause the RTC alarm to wake the system after the specified time span to + measure the system battery capacity level and estimate the battery discharging + rate, which is used for estimating the time span until the system battery + charge level goes down to 5%. This option is only used by elogind when using + the @code{'suspend-then-hibernate} action.") + + (hibernate-mode + (maybe-list-of-hibernation-modes '(platform shutdown)) + "The hibernation mode values to write to @file{/sys/power/disk} by elogind + when hibernating the system.") + + (hibernate-delay-seconds + maybe-non-negative-integer + "The amount of time the system spends in suspend mode before the system is + automatically put into hibernate mode.") + + ;; TODO: Remove in May 2026. + (hibernate-state + maybe-list-of-strings + "Deprecated option." + (serializer elogind-deprecated-empty-serializer)) + + ;; TODO: Remove in May 2026. + (hybrid-sleep-state + maybe-list-of-strings + "Deprecated option." + (serializer elogind-deprecated-empty-serializer)) + + ;; TODO: Remove in May 2026. + (hybrid-sleep-mode + maybe-list-of-strings + "Deprecated option." + (serializer elogind-deprecated-empty-serializer)) + + (prefix elogind-)) + +(define (logind.conf config) + (let ((logind-fields (remove (lambda (field) + (memq (configuration-field-name field) + %elogind-configuration-sleep-fields)) + elogind-configuration-fields))) + (match-record config + (runtime-directory-size-percent runtime-directory-size) + ;; Handle the special-cased + ;; runtime-directory-size-percent/runtime-directory-size options pair. + (let ((runtime-directory-size + (if (maybe-value-set? runtime-directory-size-percent) + (format #f "~a%~%" runtime-directory-size-percent) ;10 -> 10% + runtime-directory-size))) + (mixed-text-file + "logind.conf" + "[Login]\n" + (if (maybe-value-set? runtime-directory-size) + (list "RuntimeDirectorySize=" runtime-directory-size) + "") + (serialize-configuration config logind-fields)))))) + +(define (sleep.conf config) + (let ((sleep-fields (filter (lambda (field) + (memq (configuration-field-name field) + %elogind-configuration-sleep-fields)) + elogind-configuration-fields))) + (mixed-text-file + "sleep.conf" + "[Sleep]\n" + (serialize-configuration config sleep-fields)))) (define (elogind-etc-directory config) "Return the /etc/elogind directory for CONFIG." @@ -1213,12 +1410,19 @@ (define (elogind-etc-directory config) (chmod dest #o500))) (mkdir-p #$output) ;in case neither directory gets created + + ;; Symlink the main configuration files. + (with-directory-excursion #$output + (symlink #$(logind.conf config) "logind.conf") + (symlink #$(sleep.conf config) "sleep.conf")) + (for-each (lambda (f) (copy-script f sleep-directory)) - '#$(elogind-system-sleep-hook-files config)) + '#$(elogind-configuration-system-sleep-hook-files config)) (for-each (lambda (f) (copy-script f shutdown-directory)) - '#$(elogind-system-shutdown-hook-files config)))))) + '#$(elogind-configuration-system-shutdown-hook-files + config)))))) (define (elogind-dbus-service config) "Return a @file{org.freedesktop.login1.service} file that tells D-Bus how to @@ -1231,7 +1435,7 @@ (define (elogind-dbus-service config) ;; . (define elogind - (elogind-package config)) + (elogind-configuration-elogind config)) (define wrapper (program-file "elogind-dbus-shepherd-sync" @@ -1288,7 +1492,7 @@ (define (pam-extension-procedure config) (define pam-elogind (pam-entry (control "required") - (module (file-append (elogind-package config) + (module (file-append (elogind-configuration-elogind config) "/lib/security/pam_elogind.so")))) (list (pam-extension @@ -1301,56 +1505,52 @@ (define (pam-extension-procedure config) (define (elogind-shepherd-service config) "Return a Shepherd service to start elogind according to @var{config}." - (define config-file - (elogind-configuration-file config)) - (list (shepherd-service (requirement '(user-processes dbus-system)) (provision '(elogind)) (start #~(make-forkexec-constructor - (list #$(file-append (elogind-package config) - "/libexec/elogind/elogind")) - #:environment-variables - (list (string-append "ELOGIND_CONF_FILE=" - #$config-file)))) + (list #$(file-append (elogind-configuration-elogind config) + "/libexec/elogind/elogind")))) (stop #~(make-kill-destructor)) - (actions (list (shepherd-configuration-action config-file)))))) + (actions (list (shepherd-configuration-action + "/etc/elogind/logind.conf")))))) (define elogind-service-type - (service-type (name 'elogind) - (extensions - (list (service-extension dbus-root-service-type - elogind-dbus-service) - (service-extension udev-service-type - (compose list elogind-package)) - (service-extension polkit-service-type - (compose list elogind-package)) - - ;; Start elogind from the Shepherd rather than waiting - ;; for bus activation. This ensures that it can handle - ;; events like lid close, etc. - (service-extension shepherd-root-service-type - elogind-shepherd-service) - - ;; Provide the 'loginctl' command. - (service-extension profile-service-type - (compose list elogind-package)) - - ;; Extend PAM with pam_elogind.so. - (service-extension pam-root-service-type - pam-extension-procedure) - - ;; Install sleep/shutdown hook files. - (service-extension etc-service-type - (lambda (config) - `(("elogind" - ,(elogind-etc-directory config))))) - - ;; We need /run/user, /run/systemd, etc. - (service-extension file-system-service-type - (const %elogind-file-systems)))) - (default-value (elogind-configuration)) - (description "Run the @command{elogind} login and seat + (service-type + (name 'elogind) + (extensions + (list (service-extension dbus-root-service-type + elogind-dbus-service) + (service-extension udev-service-type + (compose list elogind-configuration-elogind)) + (service-extension polkit-service-type + (compose list elogind-configuration-elogind)) + + ;; Start elogind from the Shepherd rather than waiting + ;; for bus activation. This ensures that it can handle + ;; events like lid close, etc. + (service-extension shepherd-root-service-type + elogind-shepherd-service) + + ;; Provide the 'loginctl' command. + (service-extension profile-service-type + (compose list elogind-configuration-elogind)) + + ;; Extend PAM with pam_elogind.so. + (service-extension pam-root-service-type + pam-extension-procedure) + + ;; Install sleep/shutdown hook files. + (service-extension etc-service-type + (lambda (config) + `(("elogind" + ,(elogind-etc-directory config))))) + + ;; We need /run/user, /run/systemd, etc. + (service-extension file-system-service-type + (const %elogind-file-systems)))) + (default-value (elogind-configuration)) + (description "Run the @command{elogind} login and seat management service. The @command{elogind} service integrates with PAM to allow other system components to know the set of logged-in users as well as their session types (graphical, console, remote, etc.). It can also clean up base-commit: 5b981a2b5c9c880634d883f3b7ae078b4fa75fdb -- 2.49.0 From debbugs-submit-bounces@debbugs.gnu.org Fri Apr 25 04:14:22 2025 Received: (at 77806) by debbugs.gnu.org; 25 Apr 2025 08:14:22 +0000 Received: from localhost ([127.0.0.1]:46835 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u8ECT-0003JK-Sh for submit@debbugs.gnu.org; Fri, 25 Apr 2025 04:14:22 -0400 Received: from jpoiret.xyz ([159.223.231.69]:39236) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u8ECN-0003J0-7E for 77806@debbugs.gnu.org; Fri, 25 Apr 2025 04:14:15 -0400 From: Josselin Poiret DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1745568851; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=szJGbqRyd9Y+Lg+JKekewxZvQgOnrbT2gffzWbD2mn4=; b=OXp9YYjRQbDmQrooEyHgMhCC1mSwxmkV6z7O7A4rCHO4HcySvqmjyLPqgZZi/98+wfCgy/ IadTMW1HQpk8+r805aLVMxpNtE0bOnxp8xbl24tpi1X8LnK/3K3Ct8FF12VbCU/8XOdOAP BR0K+kqJ0paxP+Zj2SoDIGnIfxNeJZlVwHk2GG0W69npVDyMBKViyLkwgG7txnrj/uKWgF sudjsFBIckvVE5B6swnmiA9o6tFCnP56+IqxxbI8iTRmRfI9CaEtks04KKOCGgIxsiwKrE oi/SeJ+rryPG/Nt3qB4GZro8h+ge6qlG4UN0k1+hgzloG1m3AZ9wDGIPqt8sGA== Authentication-Results: jpoiret.xyz; auth=pass smtp.mailfrom=dev@jpoiret.xyz To: Maxim Cournoyer , 77806@debbugs.gnu.org Subject: Re: bug#77806: [PATCH v2] services: elogind: Split sleep.conf and port to define-configuration. In-Reply-To: <53ef49b7a94e50b4be97d0696d499e1f3d776898.1745547016.git.maxim.cournoyer@gmail.com> References: <87v7r6ofme.fsf@gnu.org> <53ef49b7a94e50b4be97d0696d499e1f3d776898.1745547016.git.maxim.cournoyer@gmail.com> Date: Fri, 25 Apr 2025 10:14:05 +0200 Message-ID: <87wmb8wtde.fsf@jpoiret.xyz> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-Spamd-Bar: / X-Spam-Score: 2.5 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Hi Maxim, Maxim Cournoyer writes: > + ;; Symlink the main configuration files. > + (with-directory-excursion #$output > + (symlink #$(logind.conf config) "logind.conf") > + (symlink #$(sleep.conf config) "sleep.conf")) Content analysis details: (2.5 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [159.223.231.69 listed in sa-trusted.bondedsender.org] -0.0 SPF_PASS SPF: sender matches SPF record 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: jpoiret.xyz (xyz)] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.0 RCVD_IN_VALIDITY_RPBL_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [159.223.231.69 listed in bl.score.senderscore.com] 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD X-Debbugs-Envelope-To: 77806 Cc: Vivien Kraus , Maxim Cournoyer , =?utf-8?Q?No=C3=A9?= Lopez , Liliana Marie Prikler , Bas Alberts , Ludovic =?utf-8?Q?Court?= =?utf-8?Q?=C3=A8s?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 2.5 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Hi Maxim, Maxim Cournoyer writes: > + ;; Symlink the main configuration files. > + (with-directory-excursion #$output > + (symlink #$(logind.conf config) "logind.conf") > + (symlink #$(sleep.conf config) "sleep.conf")) Content analysis details: (2.5 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [159.223.231.69 listed in sa-accredit.habeas.com] 0.0 RCVD_IN_VALIDITY_RPBL_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [159.223.231.69 listed in bl.score.senderscore.com] -0.0 SPF_PASS SPF: sender matches SPF record 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: jpoiret.xyz (xyz)] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 1.0 BULK_RE_SUSP_NTLD Precedence bulk and RE: from a suspicious TLD 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hi Maxim, Maxim Cournoyer writes: > + ;; Symlink the main configuration files. > + (with-directory-excursion #$output > + (symlink #$(logind.conf config) "logind.conf") > + (symlink #$(sleep.conf config) "sleep.conf")) I don't know about you, but this didn't work for me, as elogind looks for the config file in its own PKGCONFDIR (which is in the store), only looking for overrides in the /etc/elogind/*.d/ directories. Best, =2D-=20 Josselin Poiret --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQHEBAEBCAAuFiEEOSSM2EHGPMM23K8vUF5AuRYXGooFAmgLRE0QHGRldkBqcG9p cmV0Lnh5egAKCRBQXkC5FhcaigrrC/4gW++c4/Th0uR36/Z44PrK81pAC1RS0NgJ ATLV0HKw31qpkjg+ckNbhCNws2r+ooOHGwzLQoNG96rXTDkOSSCzGyUOXu7fMKGB EilxyrwWyxzwDFJ4b8XNlqgkWW1CCXTWe94MD+ZhVlrCcD197iOC1XSuEntj4RIf UDmN8NfWilzAKRe7iXEpsc95tS+27V80w7S+0lTWQIsKT7M3WCyfEc4Le/yJuevr gWbZMxaQbueSzUVeLAHc5fsu+fSq4w91mn87HWCa+Gy5PsTSV23EjSjpcNz4HFIm rVstEw8X6k8QFwiB2XxSnXm88xS6tCNMXAZHR7jQlTVWMogK7yXEPAa/wawTBgOG 0u+DFkESFJ7CeC2ohxL0Ob9iVNHNyicXmps6QtOKwe8qnBr5r1aG0oRHs+i/ByhQ AFobgilI/pqCIZal7PirhuhihCVXmDLoMio7kpxzBHvzeKswiMoF2anYKj2k8I/h krwRmyrqWwRBLim4fbvUi/wHgUBuxyI= =+KyP -----END PGP SIGNATURE----- --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Apr 25 10:12:08 2025 Received: (at 77806) by debbugs.gnu.org; 25 Apr 2025 14:12:08 +0000 Received: from localhost ([127.0.0.1]:50943 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u8Jmd-00027m-OF for submit@debbugs.gnu.org; Fri, 25 Apr 2025 10:12:08 -0400 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]:50640) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1u8JmR-00025t-2j for 77806@debbugs.gnu.org; Fri, 25 Apr 2025 10:12:00 -0400 Received: by mail-pj1-x1029.google.com with SMTP id 98e67ed59e1d1-308702998fbso2039580a91.1 for <77806@debbugs.gnu.org>; Fri, 25 Apr 2025 07:11:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745590304; x=1746195104; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=tmLim+G5oNtzbfsCblSWINOa9wa3nNsj1JYVu+WYjOk=; b=eB76JaiTO/r8AseR5/+2xu6mUfSsk3fec4VuXVdilDCPO9JDjkbGheYo1dUqOZNzy/ qVX3Kl5y2LInEsXi370f1ks4afaA2iA1RPAjSk5Lb1ZwMVcxa7epVilk+GtCpJvItJNa n9IC1si3bnE+7D3O096eeN0k7EJLvLNro/fUrXK1of5bSMDxiT80SvYLmW/rEA7z41S9 enZt3G4gDftim1/TthtpzeDjq7hiReq/NCKJx+jwwdgam0d7hyGlNuDkKLh+LP90UyiO nMIsF1pR+LtZBDrriopQbRDai/T8mMZ3KMyMTHtv3fU1P9P50p/Ccw93LQ5i+4OoUkzT XvzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745590304; x=1746195104; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=tmLim+G5oNtzbfsCblSWINOa9wa3nNsj1JYVu+WYjOk=; b=FvenUuKJPjUXKy+iue0+2+xB63oikJLGIfFdbJEdfeVqnYSSx2h9/Ig3fchIM3pjZ2 FNc040jCByhijLXwzJTl7WfmPNfPZtFizV4yC5Nbmv8f1J3NcIC8YfwXAU50e0PfnVcX Gtu8Avfvvf2KdQc1x5pWHz6efQmEC5IRbQIKSWcyM6dEbUQ9CYowFfPxlWVClwRpEA/w PB+ZgKpDP98cLAcQ2RaQCYukY6t6amfa+aRE7WP+8WGx74l8vH3Hmm/syAtWMFDhl2b3 WAIBmmYsHu7dVAVLiOt9JLKQfmq1/gnPZFJcWwsiFNbzKqDiuWvlT/CBKy09HuwC1Wa0 scWA== X-Gm-Message-State: AOJu0YyazxzBFHaWbmwuscB+Axs0cmjLb+CWxpD+CJcG59ChzZnxVk4X sgN8YjZfm/iSwvdspSuN9avRZAokEqVohA0DuNzPSBgbqolpZRv0Wg7/zA== X-Gm-Gg: ASbGncuP+ifZMQfc7wJH34S5jZNRWswNY9U9XttU3PLCNzjOemhb6zEXIPOq3yJN1Ra ABYqDbiFeX2vjbgUpCxY88hl6B2A7Pmja30jyaM/MIHdZcMhu9qlejiAucwKJTu5bHlWWBmdgEV GUWZx31r+h1kBJT6QcEqW5mIH7eWrg+MVljPZCzqBbcWzhuLRRHNkLQ/c7y529jOFsHhAyHv34w Nxs74EWcZhhDEnftsx7WvKYBCYyGIDpHPCE1A3WHkU3AfB3rw91gCKGQktgffmTFeA3wiUIbQKK ABq3sWdiPyZxzgBNMAlnDaxQjz21JJpyz7gQT2p5eFNLXzWBlYXOWkppveRB X-Google-Smtp-Source: AGHT+IEM3CPzBokVqYUu66DGOOuYavMKIBEurJf8UPfbHpBZt4DN3pFylSTKhJVOURmcBCq+t54GKQ== X-Received: by 2002:a17:90a:ad85:b0:309:fac6:44f9 with SMTP id 98e67ed59e1d1-309fac64a81mr1944311a91.31.1745590303284; Fri, 25 Apr 2025 07:11:43 -0700 (PDT) Received: from localhost.localdomain ([2405:6586:be0:0:83c8:d31d:2cec:f542]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-309f7737207sm1653048a91.5.2025.04.25.07.11.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Apr 2025 07:11:42 -0700 (PDT) From: Maxim Cournoyer To: 77806@debbugs.gnu.org Subject: [PATCH v3] services: elogind: Split sleep.conf and port to define-configuration. Date: Fri, 25 Apr 2025 23:11:33 +0900 Message-ID: <6d8ece6c552fd0fe6501da85c909e817496a5659.1745590293.git.maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.49.0 MIME-Version: 1.0 X-Debbugs-Cc: Ludovic Courtès , Bas Alberts , Maxim Cournoyer , Josselin Poiret , Liliana Marie Prikler , Noé Lopez , Vivien Kraus Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 77806 Cc: Maxim Cournoyer X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * gnu/services/desktop.scm (pascal-case): New procedure. (): Rewrite in terms of define-configuration. (elogind-configuration-file): Delete. (maybe-list-of-suspend-states?, maybe-list-of-suspend-modes?) maybe-list-of-user-names?, maybe-boolean?maybe-package?) (maybe-action?, maybe-percent?, maybe-list-of-strings?) (maybe-list-of-hibernation-modes?, maybe-non-negative-integer?) (non-negative-integer?, percent?, char-set:user-name, user-name?) (list-of-user-names?, %elogind-actions, action?, %linux-suspend-states) (string->symbol/maybe, suspend-state?, list-of-suspend-states?) (%linux-suspend-modes, suspend-mode?, list-of-suspend-modes?) (%linux-hibernation-modes, hibernation-mode?, list-of-hibernation-modes?) (elogind-deprecated-empty-serializer, list-of-file-likes?) (elogind-serialize-boolean, elogind-base-serializer, elogind-serialize-action) (elogind-serialize-non-negative-integer, elogind-serialize-percent) (elogind-list-serializer, elogind-serialize-list-of-strings) (elogind-serialize-list-of-user-names, elogind-serialize-list-of-suspend-states) (elogind-serialize-list-of-suspend-modes) (elogind-serialize-list-of-hibernation-modes) (%elogind-configuration-sleep-fields, logind.conf, sleep.conf): New procedures. (elogind-etc-directory): Create the main configuration files there too. (elogind-dbus-service): Adjust for package accessor name change. (pam-extension-procedure, elogind-shepherd-service) (elogind-service-type): Likewise. * doc/guix.texi (Desktop Services): Fully document configuration options. Fixes: bug#77806 Change-Id: I8767891871d83e58d64995ec986a7d01689fa6d8 --- doc/guix.texi | 191 +++++++----- gnu/services/desktop.scm | 630 ++++++++++++++++++++++++++------------- 2 files changed, 526 insertions(+), 295 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index be2fbbaf5bc..7b418a40892 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -26264,129 +26264,158 @@ Desktop Services @code{} object. @end defvar -@c TODO: field descriptions. This is best done by refactoring -@c elogind-configuration to use define-configuration which embeds the -@c descriptions in the code and then use configuration->documentation. +@c Auto-generated via (configuration->documentation 'elogind-configuration). +@c %start of fragment + @deftp {Data Type} elogind-configuration -Data type representing the configuration of @command{elogind}. +Available @code{elogind-configuration} fields are: @table @asis @item @code{elogind} (default: @code{elogind}) (type: file-like) -... +The elogind package to use. -@item @code{kill-user-processes?} (default: @code{#f}) (type: boolean) -... +@item @code{system-sleep-hook-files} (default: @code{()}) (type: list-of-file-likes) +A list of executables (file-like objects) that will be installed into +the @file{/etc/elogind/system-sleep} hook directory. See `Hook +directories' in the @samp{loginctl(1)} man page for more information. -@item @code{kill-only-users} (default: @code{'()}) (type: list) -... +@item @code{system-shutdown-hook-files} (default: @code{()}) (type: list-of-file-likes) +A list of executables (file-like objects) that will be installed into +the @file{/etc/elogind/system-shutdown/} hook directory. -@item @code{kill-exclude-users} (default: @code{'("root")}) (type: list-of-string) -... +@item @code{allow-power-off-interrupts?} (default: @code{#f}) (type: maybe-boolean) +Whether the executables in elogind's hook directories (see above) can +cause a power-off action to be cancelled (interrupted) by printing an +appropriate error message to stdout. -@item @code{inhibit-delay-max-seconds} (default: @code{5}) (type: integer) -... +@item @code{allow-suspend-interrupts?} (default: @code{#f}) (type: maybe-boolean) +Likewise as the @code{allow-power-off-interrupts?} option, but for the +suspend action. -@item @code{handle-power-key} (default: @code{'poweroff}) (type: symbol) -... +@item @code{broadcast-power-off-interrupts?} (default: @code{#f}) (type: maybe-boolean) +Whether an interrupt of a power-off action is broadcasted. -@item @code{handle-suspend-key} (default: @code{'suspend}) (type: symbol) -... +@item @code{broadcast-suspend-interrupts?} (default: @code{#f}) (type: maybe-boolean) +Whether an interrupt of a suspend action is broadcasted. -@item @code{handle-hibernate-key} (default: @code{'hibernate}) (type: symbol) -... +@item @code{kill-user-processes?} (default: @code{#f}) (type: maybe-boolean) +Whether the processes of a user should be killed when the user logs out. -@item @code{handle-lid-switch} (default: @code{'suspend}) (type: symbol) -... +@item @code{kill-only-users} (type: maybe-list-of-user-names) +Usernames whose processes should be killed, regardless the value of +@code{kill-user-processes?}. -@item @code{handle-lid-switch-docked} (default: @code{'ignore}) (type: symbol) -... +@item @code{kill-exclude-users} (default: @code{("root")}) (type: maybe-list-of-user-names) +Usernames whose processes should @emph{not} be killed, regardless the +value of @code{kill-user-processes?}. -@item @code{handle-lid-switch-external-power} (default: @code{*unspecified*}) (type: symbol) -... +@item @code{inhibit-delay-max-seconds} (default: @code{5}) (type: maybe-non-negative-integer) +The maximum time a system shutdown or sleep request is delayed due to an +inhibitor lock of type delay being active before the inhibitor is +ignored and the operation executes anyway. -@item @code{power-key-ignore-inhibited?} (default: @code{#f}) (type: boolean) -... +@item @code{handle-power-key} (default: @code{poweroff}) (type: maybe-action) +The action done when the power key is pressed. The compiled default is +@code{'poweroff}. -@item @code{suspend-key-ignore-inhibited?} (default: @code{#f}) (type: boolean) -... +@item @code{handle-suspend-key} (default: @code{suspend}) (type: maybe-action) +The action done when the suspend key is pressed. The -@item @code{hibernate-key-ignore-inhibited?} (default: @code{#f}) (type: boolean) -... +@item @code{handle-hibernate-key} (default: @code{hibernate}) (type: maybe-action) +The action done when the hibernate key is pressed. -@item @code{lid-switch-ignore-inhibited?} (default: @code{#t}) (type: boolean) -... +@item @code{handle-lid-switch} (default: @code{suspend}) (type: maybe-action) +The action done when the lid is closed. -@item @code{holdoff-timeout-seconds} (default: @code{30}) (type: integer) -... +@item @code{handle-lid-switch-docked} (default: @code{ignore}) (type: maybe-action) +The action done when the lid is closed and the device docked. -@item @code{idle-action} (default: @code{'ignore}) (type: symbol) -... +@item @code{handle-lid-switch-external-power} (default: @code{suspend}) (type: maybe-action) +The action done when the lid is closed and the device is externally +powered. -@item @code{idle-action-seconds} (default: @code{(* 30 60)}) (type: integer) -... +@item @code{power-key-ignore-inhibited?} (default: @code{#f}) (type: maybe-boolean) +Whether to ignore high-level inhibitor locks (shutdown, reboot, sleep or +idle) when the power key is pressed. -@item @code{runtime-directory-size-percent} (default: @code{10}) (type: integer) -... +@item @code{suspend-key-ignore-inhibited?} (default: @code{#f}) (type: maybe-boolean) +Whether to ignore high-level inhibitor locks (shutdown, reboot, sleep or +idle) when the suspend key is pressed. -@item @code{runtime-directory-size} (default: @code{#f}) (type: integer) -... +@item @code{hibernate-key-ignore-inhibited?} (default: @code{#f}) (type: maybe-boolean) +Whether to ignore high-level inhibitor locks (shutdown, reboot, sleep or +idle) when the hibernate key is pressed. -@item @code{remove-ipc?} (default: @code{#t}) (type: boolean) -... +@item @code{lid-switch-ignore-inhibited?} (default: @code{#f}) (type: maybe-boolean) +Whether to ignore high-level inhibitor locks (shutdown, reboot, sleep or +idle) when the lid is closed. -@item @code{suspend-state} (default: @code{'("mem" "standby" "freeze")}) (type: list) -... +@item @code{holdoff-timeout-seconds} (default: @code{30}) (type: maybe-non-negative-integer) +Specifies the number of seconds after system startup or system resume +during which elogind will hold off on reacting to lid events. -@item @code{suspend-mode} (default: @code{'()}) (type: list) -... +@item @code{idle-action} (default: @code{ignore}) (type: maybe-action) +Action to take when the system is idle. -@item @code{hibernate-state} (default: @code{'("disk")}) (type: list) -... +@item @code{idle-action-seconds} (type: maybe-non-negative-integer) +The delay after which the action configured in @code{idle-action} is +taken after the system is idle. -@item @code{hibernate-mode} (default: @code{'("platform" "shutdown")}) (type: list) -... +@item @code{runtime-directory-size-percent} (type: maybe-percent) +Set the size limit, in percent, on the @env{XDG_RUNTIME_DIR} runtime +directory for each user who logs in. This specifies the per-user size +limit relative to the amount of physical @acronym{RAM,read access +memory}. This value takes precedence over that specified via +@code{runtime-directory-size}. -@item @code{hybrid-sleep-state} (default: @code{'("disk")}) (type: list) -... +@item @code{runtime-directory-size} (type: maybe-non-negative-integer) +Set the size limit, in bytes, on the @env{XDG_RUNTIME_DIR} runtime +directory for each user who logs in. -@item @code{hybrid-sleep-mode} (default: @code{'("suspend" "platform" "shutdown")}) (type: list) -... +@item @code{remove-ipc?} (default: @code{#t}) (type: maybe-boolean) +Whether @acronym{IPC,inter-process communication} objects belonging to +the user shall be removed when the user fully logs out. -@item @code{hibernate-delay-seconds} (default: @code{*unspecified*}) (type: integer) -... +@item @code{suspend-state} (default: @code{(mem standby freeze)}) (type: maybe-list-of-suspend-states) +The suspend state values to be write to @file{/sys/power/state} by +elogind when suspending the system. They will be tried in turn, until +one is written without error. -@item @code{suspend-estimation-seconds} (default: @code{*unspecified*}) (type: integer) -... +@item @code{suspend-mode} (type: maybe-list-of-suspend-modes) +The suspend mode values to write to @file{/sys/power/mem_sleep} by +elogind when suspending the system. -@item @code{system-sleep-hook-files} (default: @code{'()}) (type: list) -A list of executables (file-like objects) that will be installed into -the @file{/etc/elogind/system-sleep/} hook directory. For example: +@item @code{suspend-estimation-seconds} (default: @code{3600}) (type: maybe-non-negative-integer) +Cause the RTC alarm to wake the system after the specified time span to +measure the system battery capacity level and estimate the battery +discharging rate, which is used for estimating the time span until the +system battery charge level goes down to 5%. This option is only used +by elogind when using the @code{'suspend-then-hibernate} action. -@lisp -(elogind-configuration - (system-sleep-hook-files - (list (local-file "sleep-script")))) -@end lisp +@item @code{hibernate-mode} (default: @code{(platform shutdown)}) (type: maybe-list-of-hibernation-modes) +The hibernation mode values to write to @file{/sys/power/disk} by +elogind when hibernating the system. -See `Hook directories' in the @code{loginctl(1)} man page for more information. +@item @code{hibernate-delay-seconds} (type: maybe-non-negative-integer) +The amount of time the system spends in suspend mode before the system +is automatically put into hibernate mode. -@item @code{system-shutdown-hook-files} (default: @code{'()}) (type: list) -A list of executables (file-like objects) that will be installed into -the @file{/etc/elogind/system-shutdown/} hook directory. +@item @code{hibernate-state} (type: maybe-list-of-strings) +Deprecated option. -@item @code{allow-power-off-interrupts?} (default: @code{#f}) (type: boolean) -@itemx @code{allow-suspend-interrupts?} (default: @code{#f}) (type: boolean) -Whether the executables in elogind's hook directories (see above) can -cause a power-off or suspend action to be cancelled (interrupted) by -printing an appropriate error message to stdout. +@item @code{hybrid-sleep-state} (type: maybe-list-of-strings) +Deprecated option. -@item @code{broadcast-power-off-interrupts?} (default: @code{#t}) (type: boolean) -@itemx @code{broadcast-suspend-interrupts?} (default: @code{#t}) (type: boolean) -Whether an interrupt of a power-off or suspend action is broadcasted. +@item @code{hybrid-sleep-mode} (type: maybe-list-of-strings) +Deprecated option. @end table + @end deftp + +@c %end of fragment + @defvar accountsservice-service-type Type for the service that runs AccountsService, a system service that can list available accounts, change their passwords, and so on. diff --git a/gnu/services/desktop.scm b/gnu/services/desktop.scm index fe034cfa8f4..04babf0e82d 100644 --- a/gnu/services/desktop.scm +++ b/gnu/services/desktop.scm @@ -37,6 +37,7 @@ ;;; along with GNU Guix. If not, see . (define-module (gnu services desktop) + #:use-module ((gnu home services utils) #:select (object->camel-case-string)) #:use-module (gnu services) #:use-module (gnu services shepherd) #:use-module (gnu services base) @@ -228,6 +229,8 @@ (define (package-direct-input-selector tree) (loop (cdr tree) (car (assoc-ref (package-direct-inputs package) (car tree)))))))) +(define (pascal-case text) + (object->camel-case-string text 'upper)) ;;; @@ -1025,173 +1028,367 @@ (define gvfs-service-type ;;; Elogind login and seat management service. ;;; -(define-record-type* elogind-configuration - make-elogind-configuration - elogind-configuration? - (elogind elogind-package - (default elogind)) - (kill-user-processes? elogind-kill-user-processes? - (default #f)) - (kill-only-users elogind-kill-only-users - (default '())) - (kill-exclude-users elogind-kill-exclude-users - (default '("root"))) - (inhibit-delay-max-seconds elogind-inhibit-delay-max-seconds - (default 5)) - (handle-power-key elogind-handle-power-key - (default 'poweroff)) - (handle-suspend-key elogind-handle-suspend-key - (default 'suspend)) - (handle-hibernate-key elogind-handle-hibernate-key - (default 'hibernate)) - (handle-lid-switch elogind-handle-lid-switch - (default 'suspend)) - (handle-lid-switch-docked elogind-handle-lid-switch-docked - (default 'ignore)) - (handle-lid-switch-external-power elogind-handle-lid-switch-external-power - (default *unspecified*)) - (power-key-ignore-inhibited? elogind-power-key-ignore-inhibited? - (default #f)) - (suspend-key-ignore-inhibited? elogind-suspend-key-ignore-inhibited? - (default #f)) - (hibernate-key-ignore-inhibited? elogind-hibernate-key-ignore-inhibited? - (default #f)) - (lid-switch-ignore-inhibited? elogind-lid-switch-ignore-inhibited? - (default #t)) - (holdoff-timeout-seconds elogind-holdoff-timeout-seconds - (default 30)) - (idle-action elogind-idle-action - (default 'ignore)) - (idle-action-seconds elogind-idle-action-seconds - (default (* 30 60))) - (runtime-directory-size-percent elogind-runtime-directory-size-percent - (default 10)) - (runtime-directory-size elogind-runtime-directory-size - (default #f)) - (remove-ipc? elogind-remove-ipc? - (default #t)) - - (suspend-state elogind-suspend-state - (default '("mem" "standby" "freeze"))) - (suspend-mode elogind-suspend-mode - (default '())) - (hibernate-state elogind-hibernate-state - (default '("disk"))) - (hibernate-mode elogind-hibernate-mode - (default '("platform" "shutdown"))) - (hybrid-sleep-state elogind-hybrid-sleep-state - (default '("disk"))) - (hybrid-sleep-mode elogind-hybrid-sleep-mode - (default - '("suspend" "platform" "shutdown"))) - (hibernate-delay-seconds elogind-hibernate-delay-seconds - (default *unspecified*)) - (suspend-estimation-seconds elogind-suspend-estimation-seconds - (default *unspecified*)) - (system-sleep-hook-files elogind-system-sleep-hook-files - (default '())) - (system-shutdown-hook-files elogind-system-shutdown-hook-files - (default '())) - (allow-power-off-interrupts? elogind-allow-power-off-interrupts? - (default #f)) - (allow-suspend-interrupts? elogind-allow-suspend-interrupts? - (default #f)) - (broadcast-power-off-interrupts? elogind-broadcast-power-off-interrupts? - (default #t)) - (broadcast-suspend-interrupts? elogind-broadcast-suspend-interrupts? - (default #t))) - -(define (elogind-configuration-file config) - (define (yesno x) - (match x - (#t "yes") - (#f "no") - (_ (error "expected #t or #f, instead got:" x)))) - (define char-set:user-name - (string->char-set "abcdefghijklmnopqrstuvwxyz0123456789_-")) - (define (valid-list? l pred) - (and-map (lambda (x) (string-every pred x)) l)) - (define (user-name-list users) - (unless (valid-list? users char-set:user-name) - (error "invalid user list" users)) - (string-join users " ")) - (define (enum val allowed) - (unless (memq val allowed) - (error "invalid value" val allowed)) - (symbol->string val)) - (define (non-negative-integer x) - (unless (exact-integer? x) (error "not an integer" x)) - (when (negative? x) (error "negative number not allowed" x)) - (number->string x)) - (define (maybe-non-negative-integer x) - (or (and (unspecified? x) x) - (non-negative-integer x))) - (define handle-actions - '(ignore poweroff reboot halt kexec suspend hibernate hybrid-sleep suspend-then-hibernate lock)) - (define (handle-action x) - (if (unspecified? x) - x ;let the unspecified value go through - (enum x handle-actions))) - (define (sleep-list tokens) - (unless (valid-list? tokens char-set:user-name) - (error "invalid sleep list" tokens)) - (string-join tokens " ")) - (define-syntax ini-file-clause - (syntax-rules () - ;; Produce an empty line when encountering an unspecified value. This - ;; is better than an empty string value, which can, in some cases, cause - ;; warnings such as "Failed to parse handle action setting". - ((_ config (prop (parser getter))) - (let ((value (parser (getter config)))) - (if (unspecified? value) - "" - (string-append prop "=" value "\n")))) - ((_ config str) - (if (unspecified? str) - "" - (string-append str "\n"))))) - (define-syntax-rule (ini-file config file clause ...) - (plain-file file (string-append (ini-file-clause config clause) ...))) - (ini-file - config "logind.conf" - "[Login]" - ("KillUserProcesses" (yesno elogind-kill-user-processes?)) - ("KillOnlyUsers" (user-name-list elogind-kill-only-users)) - ("KillExcludeUsers" (user-name-list elogind-kill-exclude-users)) - ("InhibitDelayMaxSec" (non-negative-integer elogind-inhibit-delay-max-seconds)) - ("HandlePowerKey" (handle-action elogind-handle-power-key)) - ("HandleSuspendKey" (handle-action elogind-handle-suspend-key)) - ("HandleHibernateKey" (handle-action elogind-handle-hibernate-key)) - ("HandleLidSwitch" (handle-action elogind-handle-lid-switch)) - ("HandleLidSwitchDocked" (handle-action elogind-handle-lid-switch-docked)) - ("HandleLidSwitchExternalPower" (handle-action elogind-handle-lid-switch-external-power)) - ("PowerKeyIgnoreInhibited" (yesno elogind-power-key-ignore-inhibited?)) - ("SuspendKeyIgnoreInhibited" (yesno elogind-suspend-key-ignore-inhibited?)) - ("HibernateKeyIgnoreInhibited" (yesno elogind-hibernate-key-ignore-inhibited?)) - ("LidSwitchIgnoreInhibited" (yesno elogind-lid-switch-ignore-inhibited?)) - ("HoldoffTimeoutSec" (non-negative-integer elogind-holdoff-timeout-seconds)) - ("IdleAction" (handle-action elogind-idle-action)) - ("IdleActionSec" (non-negative-integer elogind-idle-action-seconds)) - ("RuntimeDirectorySize" - (identity - (lambda (config) - (match (elogind-runtime-directory-size-percent config) - (#f (non-negative-integer (elogind-runtime-directory-size config))) - (percent (string-append (non-negative-integer percent) "%")))))) - ("RemoveIPC" (yesno elogind-remove-ipc?)) - "[Sleep]" - ("SuspendState" (sleep-list elogind-suspend-state)) - ("SuspendMode" (sleep-list elogind-suspend-mode)) - ("HibernateState" (sleep-list elogind-hibernate-state)) - ("HibernateMode" (sleep-list elogind-hibernate-mode)) - ("HybridSleepState" (sleep-list elogind-hybrid-sleep-state)) - ("HybridSleepMode" (sleep-list elogind-hybrid-sleep-mode)) - ("HibernateDelaySec" (maybe-non-negative-integer elogind-hibernate-delay-seconds)) - ("SuspendEstimationSec" (maybe-non-negative-integer elogind-suspend-estimation-seconds)) - ("AllowPowerOffInterrupts" (yesno elogind-allow-power-off-interrupts?)) - ("AllowSuspendInterrupts" (yesno elogind-allow-suspend-interrupts?)) - ("BroadcastPowerOffInterrupts" (yesno elogind-broadcast-power-off-interrupts?)) - ("BroadcastSuspendInterrupts" (yesno elogind-broadcast-suspend-interrupts?)))) +;;; Elogind configuration types. +(define-maybe boolean + (prefix elogind-)) + +(define (non-negative-integer? x) + (and (exact-integer? x) + (not (negative? x)))) + +(define-maybe non-negative-integer + (prefix elogind-)) + +(define (percent? x) + (and (non-negative-integer? x) + (>= x 0) + (<= x 100))) + +(define-maybe percent + (prefix elogind-)) + +(define char-set:user-name + (string->char-set "abcdefghijklmnopqrstuvwxyz0123456789_-")) + +(define (user-name? x) + (string-every char-set:user-name x)) + +(define list-of-user-names? + (list-of user-name?)) + +(define-maybe list-of-user-names + (prefix elogind-)) + +(define %elogind-actions + '( ignore poweroff reboot halt kexec suspend hibernate hybrid-sleep + suspend-then-hibernate lock factory-reset)) + +(define (action? x) + (member x %elogind-actions)) + +(define-maybe action + (prefix elogind-)) + +(define %linux-suspend-states + ;; The possible suspend states supported by the Linux kernel. + ;; See (info "(linux) Basic sysfs Interfaces for System Suspend and Hibernation"). + '(disk standby freeze mem)) + +(define (string->symbol/maybe x) + (if (string? x) + (string->symbol x) + x)) + +(define (suspend-state? x) + (member (string->symbol/maybe x) %linux-suspend-states)) + +(define list-of-suspend-states? + (list-of suspend-state?)) + +(define-maybe list-of-suspend-states + (prefix elogind-)) + +(define %linux-suspend-modes + ;; The possible suspend state variants supported by the Linux kernel. + ;; See (info "(linux) Basic sysfs Interfaces for System Suspend and Hibernation"). + '(s2idle shallow deep)) + +(define (suspend-mode? x) + (member (string->symbol/maybe x) %linux-suspend-modes)) + +(define list-of-suspend-modes? + (list-of suspend-mode?)) + +(define-maybe list-of-suspend-modes + (prefix elogind-)) + +(define %linux-hibernation-modes + ;; The possible hibernation operating modes supported by the Linux kernel. + ;; See (info "(linux) Basic sysfs Interfaces for System Suspend and Hibernation"). + '(platform shutdown reboot suspend test_resume)) + +(define (hibernation-mode? x) + (member (string->symbol/maybe x) %linux-hibernation-modes)) + +(define list-of-hibernation-modes? + (list-of hibernation-mode?)) + +(define-maybe list-of-hibernation-modes + (prefix elogind-)) + +(define (elogind-deprecated-empty-serializer name value) + (when (maybe-value-set? value) + (warn-about-deprecation name #f + #:replacement #f)) + "") + +(define list-of-file-likes? + (list-of file-like?)) + +(define-maybe list-of-strings + (prefix elogind-)) + +;;; Elogind serializers. +(define (elogind-serialize-boolean name value) + (let* ((name-str (symbol->string name)) + (name (if (string-suffix? "?" name-str) + (string-drop-right name-str 1) + name-str))) + (format #f "~a=~:[no~;yes~]~%" (pascal-case name) value))) + +(define (elogind-base-serializer name value) + (let* ((name-str (symbol->string name)) + (name (if (string-suffix? "seconds" name-str) + (string-drop-right name-str 4) ;seconds -> sec + name-str))) + (format #f "~a=~a~%" (pascal-case name) value))) + +(define elogind-serialize-action elogind-base-serializer) +(define elogind-serialize-non-negative-integer elogind-base-serializer) +(define elogind-serialize-percent elogind-base-serializer) + +(define (elogind-list-serializer name value) + (format #f "~a=~{~a~^ ~}~%" (pascal-case name) value)) + +(define elogind-serialize-list-of-strings elogind-list-serializer) +(define elogind-serialize-list-of-user-names elogind-list-serializer) +(define elogind-serialize-list-of-suspend-states elogind-list-serializer) +(define elogind-serialize-list-of-suspend-modes elogind-list-serializer) +(define elogind-serialize-list-of-hibernation-modes elogind-list-serializer) + +;;; XXX: For backward-compatible/historical reasons, the configuration object +;;; is flat, containing the fields of both the logind.conf and sleep.conf +;;; files. The list below contains the fields that should be serialized to +;;; sleep.conf. +(define %elogind-configuration-sleep-fields + '( suspend-state suspend-mode suspend-estimation-seconds + hibernate-mode hibernate-delay-seconds hibernate-state + hybrid-sleep-state hybrid-sleep-mode)) + +(define-configuration elogind-configuration + (elogind + (file-like elogind) + "The elogind package to use." + (serializer empty-serializer)) + + (system-sleep-hook-files + (list-of-file-likes '()) + "A list of executables (file-like objects) that will be installed into the +@file{/etc/elogind/system-sleep} hook directory. See `Hook directories' in +the @samp{loginctl(1)} man page for more information." + (serializer empty-serializer)) + + (system-shutdown-hook-files + (list-of-file-likes '()) + "A list of executables (file-like objects) that will be installed into the +@file{/etc/elogind/system-shutdown/} hook directory." + (serializer empty-serializer)) + + (allow-power-off-interrupts? + (maybe-boolean #f) + "Whether the executables in elogind's hook directories (see above) can + cause a power-off action to be cancelled (interrupted) by printing an + appropriate error message to stdout.") + + (allow-suspend-interrupts? + (maybe-boolean #f) + "Likewise as the @code{allow-power-off-interrupts?} option, but for the + suspend action.") + + (broadcast-power-off-interrupts? + (maybe-boolean #f) + "Whether an interrupt of a power-off action is broadcasted.") + + (broadcast-suspend-interrupts? + (maybe-boolean #f) + "Whether an interrupt of a suspend action is broadcasted.") + + ;; logind.conf options. + (kill-user-processes? + (maybe-boolean #f) + "Whether the processes of a user should be killed when the user logs + out.") + + (kill-only-users + maybe-list-of-user-names + "Usernames whose processes should be killed, regardless the value of + @code{kill-user-processes?}.") + + (kill-exclude-users + (maybe-list-of-user-names (list "root")) + "Usernames whose processes should @emph{not} be killed, regardless the + value of @code{kill-user-processes?}.") + + (inhibit-delay-max-seconds + (maybe-non-negative-integer 5) + "The maximum time a system shutdown or sleep request is delayed due to an + inhibitor lock of type delay being active before the inhibitor is ignored and + the operation executes anyway.") + + (handle-power-key + (maybe-action 'poweroff) + "The action done when the power key is pressed. The compiled default is + @code{'poweroff}.") + + (handle-suspend-key + (maybe-action 'suspend) + "The action done when the suspend key is pressed. The ") + + (handle-hibernate-key + (maybe-action 'hibernate) + "The action done when the hibernate key is pressed.") + + (handle-lid-switch + (maybe-action 'suspend) + "The action done when the lid is closed.") + + (handle-lid-switch-docked + (maybe-action 'ignore) + "The action done when the lid is closed and the device docked.") + + (handle-lid-switch-external-power + (maybe-action 'suspend) + "The action done when the lid is closed and the device is externally + powered.") + + (power-key-ignore-inhibited? + (maybe-boolean #f) + "Whether to ignore high-level inhibitor locks (shutdown, reboot, sleep or + idle) when the power key is pressed.") + + (suspend-key-ignore-inhibited? + (maybe-boolean #f) + "Whether to ignore high-level inhibitor locks (shutdown, reboot, sleep or + idle) when the suspend key is pressed.") + + (hibernate-key-ignore-inhibited? + (maybe-boolean #f) + "Whether to ignore high-level inhibitor locks (shutdown, reboot, sleep or + idle) when the hibernate key is pressed.") + + (lid-switch-ignore-inhibited? + (maybe-boolean #f) + "Whether to ignore high-level inhibitor locks (shutdown, reboot, sleep or + idle) when the lid is closed.") + + (holdoff-timeout-seconds + (maybe-non-negative-integer 30) + "Specifies the number of seconds after system startup or system resume +during which elogind will hold off on reacting to lid events.") + + (idle-action + (maybe-action 'ignore) + "Action to take when the system is idle.") + + (idle-action-seconds + maybe-non-negative-integer + "The delay after which the action configured in @code{idle-action} is +taken after the system is idle.") + + ;; XXX: Perhaps deprecate in the future and handle all the accepted forms + ;; directly in 'runtime-directory-size' instead. + (runtime-directory-size-percent + maybe-percent + "Set the size limit, in percent, on the @env{XDG_RUNTIME_DIR} runtime +directory for each user who logs in. This specifies the per-user size limit +relative to the amount of physical @acronym{RAM, read access memory}. This +value takes precedence over that specified via @code{runtime-directory-size}." + (serializer empty-serializer)) ;special cased at serialization time + + (runtime-directory-size + maybe-non-negative-integer + "Set the size limit, in bytes, on the @env{XDG_RUNTIME_DIR} runtime +directory for each user who logs in." + (serializer empty-serializer)) ;special cased at serialization time + + (remove-ipc? + (maybe-boolean #t) + "Whether @acronym{IPC, inter-process communication} objects belonging to +the user shall be removed when the user fully logs out.") + + ;; sleep.conf options. + ;; CAUTION: all sleep.conf option names must be registered in the above + ;; %ELOGIND-CONFIGURATION-SLEEP-FIELDS variable: otherwise they will be + ;; serialized to logind.conf instead of sleep.conf! + (suspend-state + (maybe-list-of-suspend-states '(mem standby freeze)) + "The suspend state values to be write to @file{/sys/power/state} by elogind + when suspending the system. They will be tried in turn, until one is written + without error.") + + (suspend-mode + (maybe-list-of-suspend-modes) + "The suspend mode values to write to @file{/sys/power/mem_sleep} by elogind + when suspending the system.") + + (suspend-estimation-seconds + (maybe-non-negative-integer (* 60 60)) ;1 hour + "Cause the RTC alarm to wake the system after the specified time span to + measure the system battery capacity level and estimate the battery discharging + rate, which is used for estimating the time span until the system battery + charge level goes down to 5%. This option is only used by elogind when using + the @code{'suspend-then-hibernate} action.") + + (hibernate-mode + (maybe-list-of-hibernation-modes '(platform shutdown)) + "The hibernation mode values to write to @file{/sys/power/disk} by elogind + when hibernating the system.") + + (hibernate-delay-seconds + maybe-non-negative-integer + "The amount of time the system spends in suspend mode before the system is + automatically put into hibernate mode.") + + ;; TODO: Remove in May 2026. + (hibernate-state + maybe-list-of-strings + "Deprecated option." + (serializer elogind-deprecated-empty-serializer)) + + ;; TODO: Remove in May 2026. + (hybrid-sleep-state + maybe-list-of-strings + "Deprecated option." + (serializer elogind-deprecated-empty-serializer)) + + ;; TODO: Remove in May 2026. + (hybrid-sleep-mode + maybe-list-of-strings + "Deprecated option." + (serializer elogind-deprecated-empty-serializer)) + + (prefix elogind-)) + +(define (logind.conf config) + (let ((logind-fields (remove (lambda (field) + (memq (configuration-field-name field) + %elogind-configuration-sleep-fields)) + elogind-configuration-fields))) + (match-record config + (runtime-directory-size-percent runtime-directory-size) + ;; Handle the special-cased + ;; runtime-directory-size-percent/runtime-directory-size options pair. + (let ((runtime-directory-size + (if (maybe-value-set? runtime-directory-size-percent) + (format #f "~a%~%" runtime-directory-size-percent) ;10 -> 10% + runtime-directory-size))) + (mixed-text-file + "logind.conf" + "[Login]\n" + (if (maybe-value-set? runtime-directory-size) + (list "RuntimeDirectorySize=" runtime-directory-size) + "") + (serialize-configuration config logind-fields)))))) + +(define (sleep.conf config) + (let ((sleep-fields (filter (lambda (field) + (memq (configuration-field-name field) + %elogind-configuration-sleep-fields)) + elogind-configuration-fields))) + (mixed-text-file + "sleep.conf" + "[Sleep]\n" + (serialize-configuration config sleep-fields)))) (define (elogind-etc-directory config) "Return the /etc/elogind directory for CONFIG." @@ -1213,12 +1410,21 @@ (define (elogind-etc-directory config) (chmod dest #o500))) (mkdir-p #$output) ;in case neither directory gets created + + ;; Symlink the main configuration files. + (with-directory-excursion #$output + (mkdir-p "logind.conf.d") + (symlink #$(logind.conf config) "logind.conf.d/logind.conf") + (mkdir-p "sleep.conf.d") + (symlink #$(sleep.conf config) "sleep.conf.d/sleep.conf")) + (for-each (lambda (f) (copy-script f sleep-directory)) - '#$(elogind-system-sleep-hook-files config)) + '#$(elogind-configuration-system-sleep-hook-files config)) (for-each (lambda (f) (copy-script f shutdown-directory)) - '#$(elogind-system-shutdown-hook-files config)))))) + '#$(elogind-configuration-system-shutdown-hook-files + config)))))) (define (elogind-dbus-service config) "Return a @file{org.freedesktop.login1.service} file that tells D-Bus how to @@ -1231,7 +1437,7 @@ (define (elogind-dbus-service config) ;; . (define elogind - (elogind-package config)) + (elogind-configuration-elogind config)) (define wrapper (program-file "elogind-dbus-shepherd-sync" @@ -1288,7 +1494,7 @@ (define (pam-extension-procedure config) (define pam-elogind (pam-entry (control "required") - (module (file-append (elogind-package config) + (module (file-append (elogind-configuration-elogind config) "/lib/security/pam_elogind.so")))) (list (pam-extension @@ -1301,56 +1507,52 @@ (define (pam-extension-procedure config) (define (elogind-shepherd-service config) "Return a Shepherd service to start elogind according to @var{config}." - (define config-file - (elogind-configuration-file config)) - (list (shepherd-service (requirement '(user-processes dbus-system)) (provision '(elogind)) (start #~(make-forkexec-constructor - (list #$(file-append (elogind-package config) - "/libexec/elogind/elogind")) - #:environment-variables - (list (string-append "ELOGIND_CONF_FILE=" - #$config-file)))) + (list #$(file-append (elogind-configuration-elogind config) + "/libexec/elogind/elogind")))) (stop #~(make-kill-destructor)) - (actions (list (shepherd-configuration-action config-file)))))) + (actions (list (shepherd-configuration-action + "/etc/elogind/logind.conf")))))) (define elogind-service-type - (service-type (name 'elogind) - (extensions - (list (service-extension dbus-root-service-type - elogind-dbus-service) - (service-extension udev-service-type - (compose list elogind-package)) - (service-extension polkit-service-type - (compose list elogind-package)) - - ;; Start elogind from the Shepherd rather than waiting - ;; for bus activation. This ensures that it can handle - ;; events like lid close, etc. - (service-extension shepherd-root-service-type - elogind-shepherd-service) - - ;; Provide the 'loginctl' command. - (service-extension profile-service-type - (compose list elogind-package)) - - ;; Extend PAM with pam_elogind.so. - (service-extension pam-root-service-type - pam-extension-procedure) - - ;; Install sleep/shutdown hook files. - (service-extension etc-service-type - (lambda (config) - `(("elogind" - ,(elogind-etc-directory config))))) - - ;; We need /run/user, /run/systemd, etc. - (service-extension file-system-service-type - (const %elogind-file-systems)))) - (default-value (elogind-configuration)) - (description "Run the @command{elogind} login and seat + (service-type + (name 'elogind) + (extensions + (list (service-extension dbus-root-service-type + elogind-dbus-service) + (service-extension udev-service-type + (compose list elogind-configuration-elogind)) + (service-extension polkit-service-type + (compose list elogind-configuration-elogind)) + + ;; Start elogind from the Shepherd rather than waiting + ;; for bus activation. This ensures that it can handle + ;; events like lid close, etc. + (service-extension shepherd-root-service-type + elogind-shepherd-service) + + ;; Provide the 'loginctl' command. + (service-extension profile-service-type + (compose list elogind-configuration-elogind)) + + ;; Extend PAM with pam_elogind.so. + (service-extension pam-root-service-type + pam-extension-procedure) + + ;; Install sleep/shutdown hook files. + (service-extension etc-service-type + (lambda (config) + `(("elogind" + ,(elogind-etc-directory config))))) + + ;; We need /run/user, /run/systemd, etc. + (service-extension file-system-service-type + (const %elogind-file-systems)))) + (default-value (elogind-configuration)) + (description "Run the @command{elogind} login and seat management service. The @command{elogind} service integrates with PAM to allow other system components to know the set of logged-in users as well as their session types (graphical, console, remote, etc.). It can also clean up base-commit: 4fe4cf9fdd959126d3c53c3df4504d851e7b736a -- 2.49.0 From debbugs-submit-bounces@debbugs.gnu.org Fri Apr 25 10:55:17 2025 Received: (at 77806) by debbugs.gnu.org; 25 Apr 2025 14:55:17 +0000 Received: from localhost ([127.0.0.1]:51255 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u8KST-00061H-8k for submit@debbugs.gnu.org; Fri, 25 Apr 2025 10:55:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60024) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u8KSP-0005y2-LK for 77806@debbugs.gnu.org; Fri, 25 Apr 2025 10:55:14 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u8KSJ-0008BH-1w; Fri, 25 Apr 2025 10:55:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=tWRWaoEdUVrw26BwqddnrQiZ569fLyR78UuqJHknME8=; b=NqZb0I+dk/dJyylwoBjP Dc0qM5Hzq+9MuDLwBSP82h6EOa5ffUVSU79gve/+0c5vzpi5zRaLfadQrCSztydEi1nn32plvYOSC hzVWyRL9qwAzttiMLW57v/7i6iHJYGmf+HU+c+hRfS2YxKEGXKr22Q9B5ygd7y9JfZZWL5cndCkz7 Gz5igx2dcgzoc2a12PzDwIwZR/ei3hQu96SUbVb4iSOcTcZ7OxrUBzKWW0MgfZGAwodBeqAykzlFx CZjGbPu3ck+91zs+8aB0nfB0GXBWAmcOYUK7XzefPiz44qzOL347kJJIQIKdd/cftJyru6t3Dh89p D/8BMUqjCit8NA==; From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Maxim Cournoyer Subject: Re: bug#77806: [PATCH v3] services: elogind: Split sleep.conf and port to define-configuration. In-Reply-To: <6d8ece6c552fd0fe6501da85c909e817496a5659.1745590293.git.maxim.cournoyer@gmail.com> (Maxim Cournoyer's message of "Fri, 25 Apr 2025 23:11:33 +0900") References: <87v7r6ofme.fsf@gnu.org> <6d8ece6c552fd0fe6501da85c909e817496a5659.1745590293.git.maxim.cournoyer@gmail.com> User-Agent: mu4e 1.12.9; emacs 29.4 X-URL: https://people.bordeaux.inria.fr/lcourtes/ X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu X-Revolutionary-Date: Sextidi 6 =?utf-8?Q?Flor=C3=A9al?= an 233 de la =?utf-8?Q?R=C3=A9volution=2C?= jour de l'Ancolie Date: Fri, 25 Apr 2025 16:54:46 +0200 Message-ID: <875xisfg09.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 77806 Cc: Josselin Poiret , Vivien Kraus , =?utf-8?Q?No=C3=A9?= Lopez , Liliana Marie Prikler , Bas Alberts , 77806@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi, Maxim Cournoyer writes: > Fixes: bug#77806 I would provide the complete URL, as is usually done, to avoid ambiguity. > + (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 let Josselin comment on the rest. Thanks for the fix! Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Sat Apr 26 10:03:25 2025 Received: (at 77806-done) by debbugs.gnu.org; 26 Apr 2025 14:03:25 +0000 Received: from localhost ([127.0.0.1]:33704 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u8g7o-000455-IP for submit@debbugs.gnu.org; Sat, 26 Apr 2025 10:03:25 -0400 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]:44032) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1u8g7l-00044O-4I for 77806-done@debbugs.gnu.org; Sat, 26 Apr 2025 10:03:22 -0400 Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-ae727e87c26so2118820a12.0 for <77806-done@debbugs.gnu.org>; Sat, 26 Apr 2025 07:03:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745676194; x=1746280994; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IhLRl7vXDZUJ/qhkqdGM6u0UKovR9qdX2fa4PH4iwNc=; b=nWPCpw/PdyyebN1A+f3UUnAuyXofnol6wqkQaRqb5IIddqnIOmozF+oB9lPGAYtHWA BviLrt6qFPAoUrCJVYagGKtEmLmHs6e5g23aG8wFCKEZZ0BfMF+vLUC+9NzcJcAJdx48 QWOJ20Tgz2ngqAQG0AXsZHJexc6n3AqEdNxj4OLz+GPeDh2IbQ4QphZpfLx5fHou3By/ 862kDJyR0LI01ZBRzmiG9lSX79lV9qQBk3EGxeQdQ7+U52vtAyLo/xZcyGS9WIm67MKo YK/Rcx18uCAk82FXgd3IfwO3dJkz62VvpczO0R0kURtjSKiekUyNKSDylQfYoGelVfcT uuCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745676194; x=1746280994; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=IhLRl7vXDZUJ/qhkqdGM6u0UKovR9qdX2fa4PH4iwNc=; b=os99gsERQaUg+sOkz51DraFYsfaCZUIlQtoLwNfKrbLqtxcfE6Ir7ANm6/ohtYBx7w ufPBeJXfIXLwu2zotIfSFIZzt9aAipDgqYubawVoDLvtDWb1P54cd4WDu6A+8OlrEB3c fPB8kb/DmeN/ucGhMj5nFLj9glj5Dd7lEkJ1A+moqRhfgJ3IxpgJ20Cqe8pgsXfWlnlg Dv3HInqHltDhZYGCdNmdw3OxxKew7jaftxJK8C4ktXdjmnyyimzjHiQ4ClW+bKCf/ZMa 0jo0HTqPvmX+rUd3qmxAOhccoh+qqAHjKsz2eSKhOrP/AhAgGntxo5y06+ijsY9GFDrx 2ZIQ== X-Forwarded-Encrypted: i=1; AJvYcCUbV+1IUq9y5yudo90Q/qumU2Q+08kOQbA3ApdrrYFWNb3hUqCOe8LFnzh69VyDsS5JSsinWC3Lu0nj@debbugs.gnu.org X-Gm-Message-State: AOJu0YyMH8lSK1gJE+Nz5kiRxbS0FXhnaK/z7qqbbelMskJgPif+37R3 aBnt5+Pctrv81DuWsBVTMDdO+KlOY6nB4NYnB7h06mTPfK4r2GLmOXus0Hbe X-Gm-Gg: ASbGncuTkt7mncp1ZCQurlljJzwjZhnFuGjHMlVHr/MGtH/khCS2XJgPO7nFbhRjGRs UA5hQJAOuU72Wp4s2RskJno1zfYE1Fie6VQDAZBRr5ylPvkGFP/nCAA3p5I2uOcTW/g584W/XHs PEGMRXe/441Dn4QwtkJlimb3LRUZZBTrd0DU1Ru/ilmoEI7RHq132LcgaVmEybqfrflex1jauoU 9NnIpmNcWjU1zZIcfuLilMvgjjYoDLI5Z60pvIdEXXTCqPtv5Mshhk0BalBHWIcHSlIaqlVc3df 3uNycMz531hUUJ6XsQ1YAcnQd8H6YNt8B/rn3Fk= X-Google-Smtp-Source: AGHT+IH9RbOvZh/ZqpFral14eDz0nAkJawFxB9wRYtWzDuV63kJ6ZR/dwMoZoXu7lOQlHNZXsPGi+Q== X-Received: by 2002:a17:902:f651:b0:224:24d3:60f4 with SMTP id d9443c01a7336-22dbf5ef6bdmr89140845ad.15.1745676193997; Sat, 26 Apr 2025 07:03:13 -0700 (PDT) Received: from terra ([2405:6586:be0:0:83c8:d31d:2cec:f542]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-22db51022f8sm50016655ad.174.2025.04.26.07.03.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Apr 2025 07:03:13 -0700 (PDT) From: Maxim Cournoyer To: Ludovic =?utf-8?Q?Court=C3=A8s?= Subject: Re: bug#77806: elogind behavior changed: power key turns computer off In-Reply-To: <875xisfg09.fsf@gnu.org> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?= =?utf-8?Q?s?= message of "Fri, 25 Apr 2025 16:54:46 +0200") References: <87v7r6ofme.fsf@gnu.org> <6d8ece6c552fd0fe6501da85c909e817496a5659.1745590293.git.maxim.cournoyer@gmail.com> <875xisfg09.fsf@gnu.org> Date: Sat, 26 Apr 2025 23:03:09 +0900 Message-ID: <87h62bdnqa.fsf_-_@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 77806-done Cc: Josselin Poiret , Vivien Kraus , =?utf-8?Q?No=C3=A9?= Lopez , Liliana Marie Prikler , Bas Alberts , 77806-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi, Ludovic Court=C3=A8s writes: > Hi, > > Maxim Cournoyer 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))))) =20 +(define* (shepherd-configuration-action* files) + "Return a 'configuration' action to display FILES, which should be the n= ames +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 con= fig) "/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)))))))) =20 (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=3Dmem standby freeze SuspendEstimationSec=3D3600 HibernateMode=3Dplatform 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! --=20 Thanks, Maxim From debbugs-submit-bounces@debbugs.gnu.org Sat May 03 12:33:06 2025 Received: (at 77806-done) by debbugs.gnu.org; 3 May 2025 16:33:06 +0000 Received: from localhost ([127.0.0.1]:42826 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uBFnV-0000js-Vz for submit@debbugs.gnu.org; Sat, 03 May 2025 12:33:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33214) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uBFnC-0000hv-Jd for 77806-done@debbugs.gnu.org; Sat, 03 May 2025 12:32:46 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uBFn4-0007Oa-0U; Sat, 03 May 2025 12:32:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=JrGORtDe4YcTBlItUKoLY9va3KCISMgjN7ebyuI5QzE=; b=TCFiyzdz7XCGJFWxm/MC QZNosruHOGY5qwqubVCRHnBQiULwe6ebbyKNNcKCfOglIjBoWx1FgxTE2Uu/r522q4XkZtrc+CgAM WqXXh8bC4lluj2nUw9y5Au9vOMtED1FzGtQhOY9BPf/VsQlodWBCdKZuZRTd+bN9hfFwXMkilr1w9 kE4b+JqL2mIR9j4YiUcBTgINvEIcVms4H6T3AocNpk/FSfUq/ka1LNmgkkZKAn3GNo4PXOBLIl4wZ 2Od1fLsv2JRDjxxMZYZqZPUNg9l4A4mQ0XSMKiFaFwlViuzPtNigwzHnyQ+QPOE+xgR1HNMWvp4Bi FYKgQMtHnx4/Ng==; From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Maxim Cournoyer Subject: Re: bug#77806: elogind behavior changed: power key turns computer off In-Reply-To: <87h62bdnqa.fsf_-_@gmail.com> (Maxim Cournoyer's message of "Sat, 26 Apr 2025 23:03:09 +0900") References: <87v7r6ofme.fsf@gnu.org> <6d8ece6c552fd0fe6501da85c909e817496a5659.1745590293.git.maxim.cournoyer@gmail.com> <875xisfg09.fsf@gnu.org> <87h62bdnqa.fsf_-_@gmail.com> User-Agent: mu4e 1.12.9; emacs 29.4 X-URL: https://people.bordeaux.inria.fr/lcourtes/ X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu X-Revolutionary-Date: Quartidi 14 =?utf-8?Q?Flor=C3=A9al?= an 233 de la =?utf-8?Q?R=C3=A9volution=2C?= jour du =?utf-8?Q?Cham=C3=A9risier?= Date: Sat, 03 May 2025 18:30:12 +0200 Message-ID: <87v7qh7j3f.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 77806-done Cc: Josselin Poiret , Vivien Kraus , =?utf-8?Q?No=C3=A9?= Lopez , Liliana Marie Prikler , Bas Alberts , 77806-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi, Maxim Cournoyer writes: > 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 to both of you for the quick fix! Ludo=E2=80=99. From unknown Thu Jun 19 13:54:41 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 01 Jun 2025 11:24:15 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator