unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: conses <contact@conses.eu>
To: 62107@debbugs.gnu.org
Cc: contact@conses.eu
Subject: [bug#62107] [PATCH v2] home: services: Add home-unclutter-service-type.
Date: Tue, 14 Mar 2023 13:36:36 +0100	[thread overview]
Message-ID: <86fsa7y0ff.fsf@conses.eu> (raw)
In-Reply-To: <86lek41cc6.fsf@conses.eu>

* gnu/home/services/desktop.scm (home-unclutter-configuration)
(home-unclutter-service-type): New variables;
(home-unclutter-shepherd-service): New procedure;
* doc/guix.texi (Desktop Services): Document it.
---
 doc/guix.texi                 | 30 ++++++++++++++++++++
 gnu/home/services/desktop.scm | 53 +++++++++++++++++++++++++++++++++--
 2 files changed, 81 insertions(+), 2 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 6671ba9305..551e5078f6 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -42541,6 +42541,36 @@ Desktop Home Services
 @end table
 @end deftp
 
+@defvar home-unclutter-service-type
+This is the service type for Unclutter, a program that runs on the
+background of an X11 session and detects when the X pointer hasn't moved
+for a specified idle timeout, after which it hides the cursor so that
+you can focus on the text underneath.  Its associated value must be a
+@code{home-unclutter-configuration} record, as shown below.
+
+A typical configuration, where we manually specify the idle timeout (in
+seconds), might look like this:
+
+@lisp
+(service home-unclutter-service-type
+         (home-unclutter-configuration
+          (idle-timeout 2)))
+@end lisp
+@end defvar
+
+@deftp {Data Type} home-unclutter-configuration
+The configuration record for @code{home-unclutter-service-type}.
+
+@table @asis
+@item @code{unclutter} (default: @code{unclutter}) (type: file-like)
+Unclutter package to use.
+
+@item @code{idle-timeout} (default: @code{5}) (type: integer)
+A timeout in seconds after which to hide cursor.
+@end table
+
+@end deftp
+
 @node Guix Home Services
 @subsection Guix Home Services
 
diff --git a/gnu/home/services/desktop.scm b/gnu/home/services/desktop.scm
index cb25b03b64..ab2b871539 100644
--- a/gnu/home/services/desktop.scm
+++ b/gnu/home/services/desktop.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2022 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2022 ( <paren@disroot.org>
+;;; Copyright © 2023 conses <contact@conses.eu>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -22,7 +23,7 @@ (define-module (gnu home services desktop)
   #:use-module (gnu home services shepherd)
   #:use-module (gnu services configuration)
   #:autoload   (gnu packages glib)    (dbus)
-  #:autoload   (gnu packages xdisorg) (redshift)
+  #:autoload   (gnu packages xdisorg) (redshift unclutter)
   #:use-module (guix records)
   #:use-module (guix gexp)
   #:use-module (srfi srfi-1)
@@ -32,7 +33,10 @@ (define-module (gnu home services desktop)
             home-redshift-service-type
 
             home-dbus-configuration
-            home-dbus-service-type))
+            home-dbus-service-type
+
+            home-unclutter-configuration
+            home-unclutter-service-type))
 
 \f
 ;;;
@@ -226,3 +230,48 @@ (define home-dbus-service-type
    (default-value (home-dbus-configuration))
    (description
     "Run the session-specific D-Bus inter-process message bus.")))
+
+\f
+;;;
+;;; Unclutter.
+;;;
+
+(define-configuration/no-serialization home-unclutter-configuration
+  (unclutter
+   (file-like unclutter)
+   "The @code{unclutter} package to use.")
+  (idle-timeout
+   (integer 5)
+   "Timeout in seconds after which to hide the cursor."))
+
+(define (home-unclutter-shepherd-service config)
+  (list
+   (shepherd-service
+    (provision '(unclutter))
+    (requirement '())
+    (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_LOG_HOME")
+                              (format #f "~a/.local/var/log"
+                                      (getenv "HOME")))
+                          "/unclutter.log"))))))
+
+(define home-unclutter-service-type
+  (service-type
+   (name 'home-unclutter)
+   (extensions
+    (list
+     (service-extension home-shepherd-service-type
+                        home-unclutter-shepherd-service)))
+   (default-value (home-unclutter-configuration))
+   (description "Run the @code{unclutter} daemon, which, on systems using the
+Xorg graphical display server, automatically hides the cursor after a
+user-defined timeout has expired.")))
-- 
2.39.1



-- 
Best regards,
conses




  parent reply	other threads:[~2023-03-14 12:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-10 22:16 [bug#62107] [PATCH] home: services: Add home-unclutter-service-type conses
2023-03-13 14:03 ` Ludovic Courtès
2023-03-14 12:35   ` conses
2023-03-14 12:36 ` conses [this message]
2023-03-16 10:51   ` bug#62107: " Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86fsa7y0ff.fsf@conses.eu \
    --to=contact@conses.eu \
    --cc=62107@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).