guix-patches
[Top][All Lists]
Advanced

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

[bug#73788] [PATCH] home: services: Fix 'home-unclutter-service-type'.


From: Fabio Natali
Subject: [bug#73788] [PATCH] home: services: Fix 'home-unclutter-service-type'.
Date: Sun, 13 Oct 2024 12:45:29 +0100

* gnu/home/services/desktop.scm: Add DISPLAY to the list of environment
variables passed to 'home-unclutter-service-type'. Change
'make-forkexec-construstor' to 'fork+exec-command' as the former did not seem to
pick up the newly defined environment variable. Add 'x11-display' as a
requirement. These changes are consistent to how things are done in
'home-redshift-service-type'.

Change-Id: Ie8b88b30353e76139d354da27aef791036eaa5a0
---
Hi All. 👋

This is to fix an issue with 'home-unclutter-service-type' where the 'DISPLAY'
environment variable was not passed to the service. Without this patch, on my
system the service fails reporting the following error message in the logs:
'unclutter: could not open display'.

This patch mirrors how things are handled in the 'home-redshift-service-type'
service, so hopefully it's fine.

Let me know what you think.

Thanks, cheers, Fabio.


 gnu/home/services/desktop.scm | 38 ++++++++++++++++++++++-------------
 1 file changed, 24 insertions(+), 14 deletions(-)

diff --git a/gnu/home/services/desktop.scm b/gnu/home/services/desktop.scm
index 679ba31c0f..dc9de168b7 100644
--- a/gnu/home/services/desktop.scm
+++ b/gnu/home/services/desktop.scm
@@ -349,21 +349,31 @@ (define (home-unclutter-shepherd-service config)
   (list
    (shepherd-service
     (provision '(unclutter))
-    (requirement '())
+    ;; Depend on 'x11-display', which sets 'DISPLAY' if an X11 server is
+    ;; available, and fails to start otherwise.
+    (requirement '(x11-display))
+    (modules '((srfi srfi-1)
+               (srfi srfi-26)))
     (one-shot? #t)
-    (start #~(make-forkexec-constructor
-              (list
-               #$(file-append
-                  (home-unclutter-configuration-unclutter config)
-                  "/bin/unclutter")
-               "-idle"
-               (number->string
-                #$(home-unclutter-configuration-idle-timeout config)))
-              #:log-file (string-append
-                          (or (getenv "XDG_STATE_HOME")
-                              (format #f "~a/.local/state"
-                                      (getenv "HOME")))
-                          "/log/unclutter.log"))))))
+    (start #~(lambda _
+               (fork+exec-command
+                (list
+                 #$(file-append
+                    (home-unclutter-configuration-unclutter config)
+                    "/bin/unclutter")
+                 "-idle"
+                 (number->string
+                  #$(home-unclutter-configuration-idle-timeout config)))
+                ;; Inherit the 'DISPLAY' variable set by 'x11-display'.
+                #:environment-variables
+                (cons (string-append "DISPLAY=" (getenv "DISPLAY"))
+                      (remove (cut string-prefix? "DISPLAY=" <>)
+                              (default-environment-variables)))
+                #:log-file (string-append
+                            (or (getenv "XDG_STATE_HOME")
+                                (format #f "~a/.local/state"
+                                        (getenv "HOME")))
+                            "/log/unclutter.log")))))))
 
 (define home-unclutter-service-type
   (service-type

base-commit: e4f5eb6c01727ef143e533019e74830e00d6f5d2
-- 
2.46.0






reply via email to

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