[PATCH] services: Add xremap service.

  • Open
  • quality assurance status badge
Details
2 participants
  • Ludovic Courtès
  • VÖRÖSK?I András
Owner
unassigned
Submitted by
VÖRÖSK?I András
Severity
normal
V
V
VÖRÖSK?I András wrote on 4 Nov 2023 16:17
(address . guix-patches@gnu.org)(name . VÖRÖSK?I András)(address . voroskoi@gmail.com)
57d94dcb19152592014053ef0bc81e95e4f6b602.1699111054.git.voroskoi@gmail.com
* 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(+)

Toggle diff (132 lines)
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.")))
+
;;;
;;; The default set of desktop services.

base-commit: 9dcd8802f5bc472579f23a38dcf437f8a9ac976c
--
2.41.0
L
L
Ludovic Courtès wrote on 2 Dec 2023 11:48
(name . VÖRÖSK?I András)(address . voroskoi@gmail.com)(address . 66932@debbugs.gnu.org)
87o7f8hoch.fsf@gnu.org
Hi András,

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

Toggle quote (7 lines)
> * 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!

Toggle quote (13 lines)
> +(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’.
V
V
VÖRÖSK?I András wrote on 4 Dec 2023 18:43
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 66932@debbugs.gnu.org)
CXFQHUW0P46H.3GYTY9F2MXN8T@wasteland
Hi Ludo,

Thanks for the reply.

On Sat Dec 2, 2023 at 11:48 AM CET, Ludovic Courtès wrote:
Toggle quote (6 lines)
> 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.

Toggle quote (3 lines)
> 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.

Toggle quote (4 lines)
> 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:

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
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 66932@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 66932
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch