all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#66932] [PATCH] services: Add xremap service.
@ 2023-11-04 15:17 VÖRÖSKŐI András
  2023-12-02 10:48 ` Ludovic Courtès
  0 siblings, 1 reply; 3+ messages in thread
From: VÖRÖSKŐI András @ 2023-11-04 15:17 UTC (permalink / raw)
  To: 66932; +Cc: VÖRÖSKŐI András

* gnu/services/desktop.scm (<xremap-configuration>): New record.
(xremap-shepherd-service): New procedure.
(xremap-service-type): New variable.
* doc/guix.texi (Desktop Services): Document this.

Change-Id: I76f9e238c72fb47226140e2b86dd9490cd9c9351
---
 doc/guix.texi            | 37 ++++++++++++++++++++++++++++++++++++
 gnu/services/desktop.scm | 41 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 78 insertions(+)

diff --git a/doc/guix.texi b/doc/guix.texi
index b90078be06..e61b4e2650 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -119,6 +119,7 @@
 Copyright @copyright{} 2023 Zheng Junjie@*
 Copyright @copyright{} 2023 Brian Cully@*
 Copyright @copyright{} 2023 Felix Lechner@*
+Copyright @copyright{} 2023 VÖRÖSKŐI András@*
 
 Permission is granted to copy, distribute and/or modify this document
 under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -25011,6 +25012,42 @@ Desktop Services
 @end table
 @end deftp
 
+@defvar xremap-service-type
+@uref{https://github.com/k0kubun/xremap/, xremap} xremap is a key remapper for
+Linux. Unlike xmodmap, it supports app-specific remapping and Wayland.
+
+@lisp
+(append
+  (list
+   (service xremap-service-type
+                    (xremap-configuration
+                     (config-file (plain-file "xremap.yml"
+"modmap:
+  - name: Global
+    remap:
+      CAPSLOCK:
+        held: CONTROL_L
+        alone: Esc
+        alone_timeout_millis: 1000"))))
+
+  ;; normally one would want %base-services
+  %base-services)
+
+@end lisp
+@end defvar
+
+@deftp {Data Type} xremap-configuration
+Configuration record for the xremap daemon service.
+
+@table @asis
+@item @code{package} (default: @code{rust-xremap})
+The xremap package to use.
+
+@item @code{config-file} (default: @samp{(plain-file "xremap.yml" "")})
+Config file to use with xremap.
+
+@end table
+@end deftp
 
 @node Sound Services
 @subsection Sound Services
diff --git a/gnu/services/desktop.scm b/gnu/services/desktop.scm
index 5b79fbcda1..1cfa7c2169 100644
--- a/gnu/services/desktop.scm
+++ b/gnu/services/desktop.scm
@@ -17,6 +17,7 @@
 ;;; Copyright © 2021, 2022 muradm <mail@muradm.net>
 ;;; Copyright © 2023 Bruno Victal <mirai@makinata.eu>
 ;;; Copyright © 2023 Zheng Junjie <873216071@qq.com>
+;;; Copyright © 2023 VÖRÖSKŐI András <voroskoi@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -72,6 +73,7 @@ (define-module (gnu services desktop)
   #:use-module (gnu packages mate)
   #:use-module (gnu packages nfs)
   #:use-module (gnu packages enlightenment)
+  #:use-module (gnu packages rust-apps)
   #:use-module (guix deprecation)
   #:use-module (guix records)
   #:use-module (guix packages)
@@ -184,6 +186,9 @@ (define-module (gnu services desktop)
             seatd-configuration
             seatd-service-type
 
+	    xremap-configuration
+	    xremap-service-type
+
             %desktop-services))
 
 ;;; Commentary:
@@ -1863,6 +1868,42 @@ (define seatd-service-type
      (service-extension shepherd-root-service-type seatd-shepherd-service)))
    (default-value (seatd-configuration))))
 
+;;;
+;;; xremap
+;;;
+
+(define-record-type* <xremap-configuration>
+  xremap-configuration make-xremap-configuration
+  xremap-configuration?
+  (package xremap-configuration-package
+           (default rust-xremap))
+  (config-file xremap-configuration-config-file
+           (default (plain-file "xremap.yml" ""))))
+
+(define (xremap-shepherd-service config)
+  "Return an <sheperd-service> for xremap with CONFIG"
+  (match-record config <xremap-configuration>
+                (package config-file)
+                (list
+                (shepherd-service
+                 (provision '(xremap))
+                 (documentation "xremap daemon")
+                 (requirement '())
+                 (start #~(make-forkexec-constructor
+                           (list #$(file-append package "/bin/xremap")
+                                 #$config-file)))
+                 (stop #~(make-kill-destructor))))))
+
+(define xremap-service-type
+  (service-type
+   (name 'xremap)
+   (extensions
+    (list
+     (service-extension shepherd-root-service-type
+                        xremap-shepherd-service)))
+   (default-value (xremap-configuration))
+   (description "Run the @code{xremap} utility to modify keymaps system wide.")))
+
 \f
 ;;;
 ;;; The default set of desktop services.

base-commit: 9dcd8802f5bc472579f23a38dcf437f8a9ac976c
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [bug#66932] [PATCH] services: Add xremap service.
  2023-11-04 15:17 [bug#66932] [PATCH] services: Add xremap service VÖRÖSKŐI András
@ 2023-12-02 10:48 ` Ludovic Courtès
  2023-12-04 17:43   ` VÖRÖSKŐI András
  0 siblings, 1 reply; 3+ messages in thread
From: Ludovic Courtès @ 2023-12-02 10:48 UTC (permalink / raw)
  To: VÖRÖSKŐI András; +Cc: 66932

Hi András,

VÖRÖSKŐI András <voroskoi@gmail.com> skribis:

> * gnu/services/desktop.scm (<xremap-configuration>): New record.
> (xremap-shepherd-service): New procedure.
> (xremap-service-type): New variable.
> * doc/guix.texi (Desktop Services): Document this.
>
> Change-Id: I76f9e238c72fb47226140e2b86dd9490cd9c9351

Nice!

> +(append
> +  (list
> +   (service xremap-service-type
> +                    (xremap-configuration
> +                     (config-file (plain-file "xremap.yml"
> +"modmap:
> +  - name: Global
> +    remap:
> +      CAPSLOCK:
> +        held: CONTROL_L
> +        alone: Esc
> +        alone_timeout_millis: 1000"))))

Did you consider writing “bindings” so that one can configure it Scheme,
as is the case for most other services?  (To be clear, I think we should
still allow people to provide their own Yaml file as is done here.)

If that’s too tricky/impractical, we can keep the patch as is, but
adding “native” configuration on top of that would be sweet.

I wonder if it would make sense, in a future patch, to also provide
‘home-xremap-service-type’ as a direct mapping of this service.  Food
for thought.

Thanks,
Ludo’.




^ permalink raw reply	[flat|nested] 3+ messages in thread

* [bug#66932] [PATCH] services: Add xremap service.
  2023-12-02 10:48 ` Ludovic Courtès
@ 2023-12-04 17:43   ` VÖRÖSKŐI András
  0 siblings, 0 replies; 3+ messages in thread
From: VÖRÖSKŐI András @ 2023-12-04 17:43 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 66932

Hi Ludo,

Thanks for the reply.

On Sat Dec 2, 2023 at 11:48 AM CET, Ludovic Courtès wrote:
> Hi András,
>
> Did you consider writing “bindings” so that one can configure it Scheme,
> as is the case for most other services?  (To be clear, I think we should
> still allow people to provide their own Yaml file as is done here.)

I did consider that, but I am not familiar with guile, so that is too
hard for me and there are a lot of combinations to handle.

> If that’s too tricky/impractical, we can keep the patch as is, but
> adding “native” configuration on top of that would be sweet.

It is tricky for me and telling the truth I do not see the benefit.

> I wonder if it would make sense, in a future patch, to also provide
> ‘home-xremap-service-type’ as a direct mapping of this service.  Food
> for thought.

I was thinking about that, but was not sure. There is a section in the README about that:
https://github.com/k0kubun/xremap#running-xremap-without-sudo

The basic idea is creating an input group with write permission for every
input type.
I think we can not automate the "add user to input group" in the home-service,
so that would be still a manual task.

Is this solution acceptable?

Thanks,
András




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-12-04 18:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-04 15:17 [bug#66932] [PATCH] services: Add xremap service VÖRÖSKŐI András
2023-12-02 10:48 ` Ludovic Courtès
2023-12-04 17:43   ` VÖRÖSKŐI András

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.