guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

branch master updated: services: elogind-configuration-file: Do not seri


From: guix-commits
Subject: branch master updated: services: elogind-configuration-file: Do not serialize unspecified items.
Date: Fri, 16 Sep 2022 12:07:36 -0400

This is an automated email from the git hooks/post-receive script.

apteryx pushed a commit to branch master
in repository guix.

The following commit(s) were added to refs/heads/master by this push:
     new 106660e3ff services: elogind-configuration-file: Do not serialize 
unspecified items.
106660e3ff is described below

commit 106660e3ff4f111bc9779193376a53beee4585b5
Author: Maxim Cournoyer <maxim.cournoyer@gmail.com>
AuthorDate: Fri Sep 16 11:11:06 2022 -0400

    services: elogind-configuration-file: Do not serialize unspecified items.
    
    This a followup to 59ee837d8b11d7d688045b601e8b240ccbdbe7c7, which changed 
the
    default value of the HandleLidSwitchExternalPower to the empty string.
    Unfortunately this causes elogind to print a warning (although it otherwise
    works as intended).  This change fixes that.
    
    * gnu/services/desktop.scm (elogind-configuration-file)<handle-action>: Let
    the unspecified value go through.
    <ini-file-clause>: When an unspecified file is encountered, do not produce 
any
    text to serialize.
---
 gnu/services/desktop.scm | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/gnu/services/desktop.scm b/gnu/services/desktop.scm
index 07e7500847..9b3eb12613 100644
--- a/gnu/services/desktop.scm
+++ b/gnu/services/desktop.scm
@@ -1034,7 +1034,7 @@ include the @command{udisksctl} command, part of UDisks, 
and GNOME Disks."
     '(ignore poweroff reboot halt kexec suspend hibernate hybrid-sleep lock))
   (define (handle-action x)
     (if (unspecified? x)
-        ""                              ;empty serializer
+        x                               ;let the unspecified value go through
         (enum x handle-actions)))
   (define (sleep-list tokens)
     (unless (valid-list? tokens char-set:user-name)
@@ -1042,10 +1042,18 @@ include the @command{udisksctl} command, part of 
UDisks, and GNOME Disks."
     (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)))
-       (string-append prop "=" (parser (getter config)) "\n"))
+       (let ((value (parser (getter config))))
+         (if (unspecified? value)
+             ""
+             (string-append prop "=" value "\n"))))
       ((_ config str)
-       (string-append str "\n"))))
+       (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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]