From unknown Mon Jun 23 07:50:01 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#62101 <62101@debbugs.gnu.org> To: bug#62101 <62101@debbugs.gnu.org> Subject: Status: [PATCH] home: services: Add xmodmap. Reply-To: bug#62101 <62101@debbugs.gnu.org> Date: Mon, 23 Jun 2025 14:50:01 +0000 retitle 62101 [PATCH] home: services: Add xmodmap. reassign 62101 guix-patches submitter 62101 conses severity 62101 normal tag 62101 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Fri Mar 10 14:58:02 2023 Received: (at submit) by debbugs.gnu.org; 10 Mar 2023 19:58:03 +0000 Received: from localhost ([127.0.0.1]:55908 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1paisM-00082G-Bm for submit@debbugs.gnu.org; Fri, 10 Mar 2023 14:58:02 -0500 Received: from lists.gnu.org ([209.51.188.17]:38334) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1paisJ-00081m-Mp for submit@debbugs.gnu.org; Fri, 10 Mar 2023 14:58:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1paisJ-0007Fw-Fy for guix-patches@gnu.org; Fri, 10 Mar 2023 14:57:59 -0500 Received: from relay4-d.mail.gandi.net ([217.70.183.196]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1paisH-0005iq-Bv for guix-patches@gnu.org; Fri, 10 Mar 2023 14:57:59 -0500 Received: (Authenticated sender: contact@conses.eu) by mail.gandi.net (Postfix) with ESMTPSA id C7A87E0008; Fri, 10 Mar 2023 19:57:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=conses.eu; s=gm1; t=1678478272; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=HiC8CJnn1Z4Gk7bduk1B10PKxdivXuoTDS/TUzCP5B0=; b=KWkU7L5VSdp8h7u1DOYE6OsCLm5JKatHO7SZoT4Ks+786gC4CUj3L8uCGbRWdtk49ScjqB bX1BR4hku+TDRKVqiULIr62japnUkCtagIY2A5sY+pcCTTSXuaGeCCcODaD3+FC6ODr6UW kF41aG8jDELLmfrxovFNd0niJ1P9rEQ1s9+O2MMvzqu8ZWWpMNvqq2Ax5IpKuwScDhCaUy +JKzT+OpLdJG5we0jtm6yZ4YIyhwV4lgqWBEKkqA6KOTiGTX9YFtFQ6gYYie6qgjfAnmxC HwaaAFpFMhz5rSU6xcxp8mSrTerMaRBKvy9U+XNzisAc7tKFwSheq0tShLrTQA== From: conses To: guix-patches@gnu.org Subject: [PATCH] home: services: Add xmodmap. Date: Fri, 10 Mar 2023 20:57:48 +0100 Message-ID: <867cvo9y6b.fsf@conses.eu> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=217.70.183.196; envelope-from=contact@conses.eu; helo=relay4-d.mail.gandi.net X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.6 (-) X-Debbugs-Envelope-To: submit Cc: contact@conses.eu, Andrew Tropin X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.6 (--) --- gnu/home/services/desktop.scm | 109 ++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) diff --git a/gnu/home/services/desktop.scm b/gnu/home/services/desktop.scm index cb25b03b64..b3c60b017e 100644 --- a/gnu/home/services/desktop.scm +++ b/gnu/home/services/desktop.scm @@ -22,10 +22,13 @@ (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 xorg) (xmodmap) #:autoload (gnu packages xdisorg) (redshift) + #:use-module (guix packages) #:use-module (guix records) #:use-module (guix gexp) #:use-module (srfi srfi-1) + #:use-module (srfi srfi-43) #:use-module (ice-9 match) #:export (home-redshift-configuration home-redshift-configuration? @@ -226,3 +229,109 @@ (define home-dbus-service-type (default-value (home-dbus-configuration)) (description "Run the session-specific D-Bus inter-process message bus."))) + + +;;; +;;; xmodmap +;;; + +(define-configuration/no-serialization home-xmodmap-configuration + (xmodmap + (package xmodmap) + "The @code{xmodmap} package to use.") + (config + (alist '()) + "Association list of key and value pairs for the + @code{xmodmap} configuration file. Its syntax can take something like +the following: + +@example +'((#(add mod4) . Print) + (clear lock) + (clear control) + (#(keycode 66) . Control_L) + (#(add control) . #(Control_L Control_R))) +@end example")) + +(define (home-xmodmap-shepherd-service config) + (list + (shepherd-service + (provision '(xmodmap)) + (start #~(make-system-constructor + (string-join + (list #$(file-append + (home-xmodmap-configuration-xmodmap config) + "/bin/xmodmap") + #$(home-xmodmap-file config))))) + (one-shot? #t)))) + +(define (get-xmodmap-configuration field-name val) + (define serialize-term + (match-lambda + ((? vector? e) + (string-join + (vector-fold + (lambda (i acc e) + (append + acc + (list (serialize-term e)))) + '() e) " ")) + ((? symbol? e) (symbol->string e)) + ((? number? e) (number->string e)) + (e e))) + + (define serialize-field + (match-lambda + ((? list? e) + (string-join + (map + (lambda (x) + (serialize-term x)) + e) + " ")) + ((key . value) + (format #f "~a = ~a" + (serialize-term key) + (serialize-term value))) + (key (string-append (serialize-term key))))) + + #~(string-append + #$@(interpose + (map serialize-field val) + "\n" 'suffix))) + +(define (home-xmodmap-files-service config) + `(("xmodmap/config" + ,(home-xmodmap-file config)))) + +(define (home-xmodmap-file config) + (mixed-text-file + "config" + (get-xmodmap-configuration + #f (home-xmodmap-configuration-config config)))) + +(define (home-xmodmap-profile-service config) + (list (home-xmodmap-configuration-xmodmap config))) + +(define home-xmodmap-service-type + (service-type + (name 'home-xmodmap) + (extensions + (list + (service-extension + home-profile-service-type + home-xmodmap-profile-service) + (service-extension + home-xdg-configuration-files-service-type + home-xmodmap-files-service) + (service-extension + home-shepherd-service-type + home-xmodmap-shepherd-service))) + (description "Configure @code{xmodmap} bindings and rules.") + (default-value (home-xmodmap-configuration)))) + +(define (generate-home-xmodmap-documentation) + (generate-documentation + `((home-xmodmap-configuration + ,home-xmodmap-configuration-fields)) + 'home-xmodmap-configuration)) -- 2.39.1 -- Best regards, conses From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 13 10:00:29 2023 Received: (at 62101) by debbugs.gnu.org; 13 Mar 2023 14:00:29 +0000 Received: from localhost ([127.0.0.1]:35250 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pbiiz-00077Q-B7 for submit@debbugs.gnu.org; Mon, 13 Mar 2023 10:00:29 -0400 Received: from eggs.gnu.org ([209.51.188.92]:56958) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pbiix-0006og-G7 for 62101@debbugs.gnu.org; Mon, 13 Mar 2023 10:00:27 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pbiir-0004HZ-A2; Mon, 13 Mar 2023 10:00:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=7iXUwcWMwldcJAycZWm/KopK45atzqlbxt//ShuSlg8=; b=HysJMJWpWoz4CGhQN+Rl KSmwl9SsuEX4NGd46zpQo/WnIUZLvspYvG157ZLrHqNrLap2Eec88pJ7RGxZw76ega40L8TPMyPyO EyO635Prsk9aXaJq7eFd3FqKVO2YKhJtXICYLnkKfX43b9gc9pMwMk4mDnk3vhLfjhSqko0fVIftC 2adYJW7rklmlRpXme5RlrjBFpEltJRTOFgbyX1LRQTNhXFK5FUSXnTS08j16/b7wNkM8P5MKArUpW mmp16AugYnDkBlFsrNwQP0UlfhxE0RfTXnjkE+4T40bLLsD5GalGA3ZRPuRz+lRCxpyD9QFFSbVZN 0y/bjtNNcGUutg==; Received: from [193.50.110.253] (helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pbiiq-0002PF-So; Mon, 13 Mar 2023 10:00:21 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: conses Subject: Re: bug#62101: [PATCH] home: services: Add xmodmap. References: <867cvo9y6b.fsf@conses.eu> Date: Mon, 13 Mar 2023 15:00:17 +0100 In-Reply-To: <867cvo9y6b.fsf@conses.eu> (conses's message of "Fri, 10 Mar 2023 20:57:48 +0100") Message-ID: <87wn3k21la.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 62101 Cc: Andrew Tropin , 62101@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hello, This looks like a useful addition! Some comments below; maybe Andrew will bring a different perspective. conses skribis: > --- > gnu/home/services/desktop.scm | 109 ++++++++++++++++++++++++++++++++++ It=E2=80=99d be great if you could provide a ChangeLog-style commit log (yo= u can check the manual and =E2=80=98git log=E2=80=99 to see what it=E2=80=99s lik= e); if you can=E2=80=99t, we can help with that. More importantly, could you add documentation to guix.texi, similar to what is done for the other Home services? That is: a few introductory lines, an example, and the reference (data types, variables, procedures). > + (alist '()) > + "Association list of key and value pairs for the > + @code{xmodmap} configuration file. Its syntax can take something like > +the following: > + > +@example > +'((#(add mod4) . Print) > + (clear lock) > + (clear control) > + (#(keycode 66) . Control_L) > + (#(add control) . #(Control_L Control_R))) > +@end example")) I don=E2=80=99t quite get the syntax. Use of vectors is unusual in this context, I=E2=80=99d recommend against it. Regarding pairs: in some cases, the cdr is a symbol/vector, in other cases it=E2=80=99s a one-element list (as in =E2=80=98(clear lock)=E2=80=99= ). That also makes it a bit confusing to me. Perhaps we should try to make it look more consistent? WDYT? > +(define (home-xmodmap-shepherd-service config) > + (list > + (shepherd-service > + (provision '(xmodmap)) > + (start #~(make-system-constructor > + (string-join > + (list #$(file-append > + (home-xmodmap-configuration-xmodmap config) > + "/bin/xmodmap") > + #$(home-xmodmap-file config))))) > + (one-shot? #t)))) Perhaps it=E2=80=99d be useful to have a =E2=80=98stop=E2=80=99 procedure t= hat undoes that changes? In which case it wouldn=E2=80=99t be one-shot anymore. > + (define serialize-field > + (match-lambda > + ((? list? e) > + (string-join > + (map > + (lambda (x) > + (serialize-term x)) > + e) > + " ")) Just: (string-join (map serialize-term e)). > +(define home-xmodmap-service-type > + (service-type > + (name 'home-xmodmap) > + (extensions > + (list > + (service-extension > + home-profile-service-type > + home-xmodmap-profile-service) > + (service-extension > + home-xdg-configuration-files-service-type > + home-xmodmap-files-service) > + (service-extension > + home-shepherd-service-type > + home-xmodmap-shepherd-service))) > + (description "Configure @code{xmodmap} bindings and rules.") Please expand the description a bit. TIA! Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Thu Mar 16 09:03:46 2023 Received: (at 62101) by debbugs.gnu.org; 16 Mar 2023 13:03:46 +0000 Received: from localhost ([127.0.0.1]:41459 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pcnGj-0007QR-OZ for submit@debbugs.gnu.org; Thu, 16 Mar 2023 09:03:46 -0400 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:53425) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pcnGh-0007Q9-Nk for 62101@debbugs.gnu.org; Thu, 16 Mar 2023 09:03:44 -0400 Received: (Authenticated sender: contact@conses.eu) by mail.gandi.net (Postfix) with ESMTPSA id E7E3560016; Thu, 16 Mar 2023 13:03:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=conses.eu; s=gm1; t=1678971817; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=0++0oWJxtxz2RK0NRP4AsC5gDXyjd/mgehbPwsVc3MU=; b=a1/QRAokSb8kouz6GyyTJRCwQ/haVtJJ7TxgANfa8GQL39W04J6AdVzna0ZspzCK++0jTL 1UFvVY0MjbJr+EBNucJhj/QPdHIg+4sDSbkcS6OI+Lr28vSJ6wpcnna+xXJDvi0B+xy0TD xcANA8ALlCu+zvr8i+txSoLvpNQZ1GMGPftws4Z8BmhBObrcbFZVt4ME+swdBe5oLyMqXC MYpRFF4tOmPguUYSG40Sl73JVKBCbpQF/gNx/u2dxE9qj/Is2lDDpcH7R6uAdZrrCzvErZ 7cBShQX8veg1s3nU0bwpV2WCWMy7l6HfUwKS+rnhwUOFv/TS8ZdQMeD4CiR2aA== From: conses To: Ludovic =?utf-8?Q?Court=C3=A8s?= Subject: [PATCH v2] home: services: Add home-xmodmap-service-type. Date: Thu, 16 Mar 2023 14:03:34 +0100 Message-ID: <86edpox2zd.fsf@conses.eu> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 62101 Cc: contact@conses.eu, 62101@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) * gnu/home/services/desktop.scm (home-xmodmap-service-type) (home-xmodmap-configuration): New variables; (xmodmap-shepherd-service) (get-xmodmap-configuration) (get-xmodmap-file) (add-xmodmap-config-file) (add-xmodmap-package): New procedures; * doc/guix.texi (Desktop Services): Document it. --- doc/guix.texi | 51 +++++++++++++++++++++ gnu/home/services/desktop.scm | 85 +++++++++++++++++++++++++++++++++++ 2 files changed, 136 insertions(+) diff --git a/doc/guix.texi b/doc/guix.texi index 6671ba9305..c9ec781e8b 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -42541,6 +42541,57 @@ Desktop Home Services @end table @end deftp +@defvar home-xmodmap-service-type +This is the service type for the +@uref{https://gitlab.freedesktop.org/xorg/app/xmodmap,xmodmap} utility +to modify keymaps and pointer button mappings under the Xorg display +server. Its associated value must be a +@code{home-xmodmap-configuration} record, as shown below. + +The syntax for the expression grammar is quite straightforward. You can +either provide a list of cons cells and strings like this: + +@lisp +(service home-xmodmap-service-type + (home-xmodmap-configuration + (config '(("add mod4" . "Print") + "clear lock" + "clear control" + ("keycode 66" . "Control_L") + ("add control" . "Control_L Control_R"))))) +@end lisp + +Alternatively, there is a more Lisp-like configuration syntax via Scheme +symbols, lists, and vectors, that you can use like this: + +@lisp +(service home-xmodmap-service-type + (home-xmodmap-configuration + (config '((#(add mod4) . Print) + (clear lock) + (clear control) + (#(keycode 66) . Control_L) + (#(add control) . #(Control_L Control_R)))))) +@end lisp +@end defvar + +@deftp {Data Type} home-xmodmap-configuration +The configuration record for @code{home-xmodmap-service-type}. Its +available fields are: + +@table @asis +@item @code{xmodmap} (default: @code{xmodmap}) (type: file-like) +The @code{xmodmap} package to use. + +@item @code{config} (default: @code{config}) (type: list) +The list of expressions to be placed in the +@file{~/.config/xmodmap/config} configuration file and read on service +startup. + +@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..8bc3d82cba 100644 --- a/gnu/home/services/desktop.scm +++ b/gnu/home/services/desktop.scm @@ -22,10 +22,12 @@ (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 xorg) (setxkbmap xmodmap) #:autoload (gnu packages xdisorg) (redshift) #:use-module (guix records) #:use-module (guix gexp) #:use-module (srfi srfi-1) + #:use-module (srfi srfi-43) #:use-module (ice-9 match) #:export (home-redshift-configuration home-redshift-configuration? @@ -226,3 +228,86 @@ (define home-dbus-service-type (default-value (home-dbus-configuration)) (description "Run the session-specific D-Bus inter-process message bus."))) + + +;;; +;;; xmodmap +;;; + +(define-configuration/no-serialization home-xmodmap-configuration + (xmodmap + (file-like xmodmap) + "The @code{xmodmap} package to use.") + (config + (list '()) + "List of expressions to be inserted in the @file{.config/xmodmap/config} +configuration file.")) + +(define (xmodmap-shepherd-service config) + (list + (shepherd-service + (provision '(xmodmap)) + (start #~(make-system-constructor + (string-join + (list #$(file-append + (home-xmodmap-configuration-xmodmap config) + "/bin/xmodmap") + #$(get-xmodmap-file config))))) + (stop #~(make-system-constructor + #$(file-append setxkbmap "/bin/setxkbmap"))) + (documentation "On startup, run @code{xmodmap} and read the expressions in +the configuration file. On stop, reset all the mappings back to the +defaults.")))) + +(define (get-xmodmap-configuration field-name val) + (define serialize-term + (match-lambda + ((? vector? e) + (string-join + (vector-fold (lambda (_ acc e) + (append acc (list (serialize-term e)))) + '() e))) + ((? symbol? e) (symbol->string e)) + ((? number? e) (number->string e)) + (e e))) + + (define serialize-field + (match-lambda + ((? list? e) + (string-join (map serialize-term e))) + ((key . value) + (format #f "~a = ~a" (serialize-term key) (serialize-term value))) + (key (string-append (serialize-term key))))) + + #~(string-append + #$@(interpose + (map serialize-field val) + "\n" 'suffix))) + +(define (get-xmodmap-file config) + (mixed-text-file + "config" + (get-xmodmap-configuration + #f (home-xmodmap-configuration-config config)))) + +(define (add-xmodmap-config-file config) + `(("xmodmap/config" + ,(get-xmodmap-file config)))) + +(define (add-xmodmap-package config) + (list (home-xmodmap-configuration-xmodmap config))) + +(define home-xmodmap-service-type + (service-type + (name 'home-xmodmap) + (extensions + (list + (service-extension home-profile-service-type + add-xmodmap-package) + (service-extension home-xdg-configuration-files-service-type + add-xmodmap-config-file) + (service-extension home-shepherd-service-type + xmodmap-shepherd-service))) + (default-value (home-xmodmap-configuration)) + (description "Run the @code{xmodmap} utility to modify keymaps and pointer +buttons under the Xorg display server via user-defined expressions."))) -- 2.39.1 -- Best regards, conses From debbugs-submit-bounces@debbugs.gnu.org Thu Mar 16 09:15:43 2023 Received: (at 62101) by debbugs.gnu.org; 16 Mar 2023 13:15:43 +0000 Received: from localhost ([127.0.0.1]:41472 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pcnSI-0007jg-GH for submit@debbugs.gnu.org; Thu, 16 Mar 2023 09:15:42 -0400 Received: from relay10.mail.gandi.net ([217.70.178.230]:46181) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pcnSG-0007jU-D9 for 62101@debbugs.gnu.org; Thu, 16 Mar 2023 09:15:41 -0400 Received: (Authenticated sender: contact@conses.eu) by mail.gandi.net (Postfix) with ESMTPSA id CCBE4240007; Thu, 16 Mar 2023 13:15:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=conses.eu; s=gm1; t=1678972534; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JaMgJF5+wwrSf5VciuzwW5gY/MMPhK+aFB5jY+4Oh0Y=; b=ZuYu0GGSiQyXT8B/i+sgOXLy4/z+zBbKVPAhgN6zs9L/a7k+UkgLoUWe+VRuJlmeprktfg xipup0SOw4/K37I5B0cOCwU27Tdig5tPrJfctXNjQ6BAwkWtbLTp5WRlQW9INQWwU66+lT bpkIg/Ju+MQNi01gLzcO9qBnsZ+wioxlkjom6UPYH4Mec6iEe0Ks7N+mAYRtIhhyoekdPB AGtgYOyESjduIyq55iB+2PxCsHX7SCLuyhvZZaktWedPD+NaRwjamptsYzNisiuPce8d9L AwGp97otJCshZklQnm2HoeN8WdIMey/AWTXRrmmPk+HOugtnwUYO5ziXMVqtFw== From: conses To: Ludovic =?utf-8?Q?Court=C3=A8s?= Subject: Re: bug#62101: [PATCH] home: services: Add xmodmap. In-Reply-To: <87wn3k21la.fsf@gnu.org> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?= =?utf-8?Q?s?= message of "Mon, 13 Mar 2023 15:00:17 +0100") References: <867cvo9y6b.fsf@conses.eu> <87wn3k21la.fsf@gnu.org> Date: Thu, 16 Mar 2023 14:15:32 +0100 Message-ID: <86a60cx2ff.fsf@conses.eu> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 62101 Cc: contact@conses.eu, 62101@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Ludovic Court=C3=A8s writes: > It=E2=80=99d be great if you could provide a ChangeLog-style commit log (= you can > check the manual and =E2=80=98git log=E2=80=99 to see what it=E2=80=99s l= ike); if you can=E2=80=99t, we > can help with that. > Apologies for missing this, I added it in v2. > More importantly, could you add documentation to guix.texi, similar to > what is done for the other Home services? That is: a few introductory > lines, an example, and the reference (data types, variables, > procedures). > Likewise. >> + (alist '()) >> + "Association list of key and value pairs for the >> + @code{xmodmap} configuration file. Its syntax can take something like >> +the following: >> + >> +@example >> +'((#(add mod4) . Print) >> + (clear lock) >> + (clear control) >> + (#(keycode 66) . Control_L) >> + (#(add control) . #(Control_L Control_R))) >> +@end example")) > > I don=E2=80=99t quite get the syntax. > > Use of vectors is unusual in this context, I=E2=80=99d recommend against = it. > > Regarding pairs: in some cases, the cdr is a symbol/vector, in other > cases it=E2=80=99s a one-element list (as in =E2=80=98(clear lock)=E2=80= =99). That also makes > it a bit confusing to me. > > Perhaps we should try to make it look more consistent? WDYT? I've amended the type of config to be of list instead. As I've hinted in the manual, the motivation for including vectors and lists is to provide a more Lisp-like configuration syntax for those that want it, it can simply take strings too. IMO there's no point in making it consistent since the original syntax isn't consistent in the first place, you can check out some examples here . > >> +(define (home-xmodmap-shepherd-service config) >> + (list >> + (shepherd-service >> + (provision '(xmodmap)) >> + (start #~(make-system-constructor >> + (string-join >> + (list #$(file-append >> + (home-xmodmap-configuration-xmodmap config) >> + "/bin/xmodmap") >> + #$(home-xmodmap-file config))))) >> + (one-shot? #t)))) > > Perhaps it=E2=80=99d be useful to have a =E2=80=98stop=E2=80=99 procedure= that undoes that > changes? In which case it wouldn=E2=80=99t be one-shot anymore. > I found here that xmodmap settings can be simply reversed by calling setxkbmap, so I've added a stop procedure for this. >> +(define home-xmodmap-service-type >> + (service-type >> + (name 'home-xmodmap) >> + (extensions >> + (list >> + (service-extension >> + home-profile-service-type >> + home-xmodmap-profile-service) >> + (service-extension >> + home-xdg-configuration-files-service-type >> + home-xmodmap-files-service) >> + (service-extension >> + home-shepherd-service-type >> + home-xmodmap-shepherd-service))) >> + (description "Configure @code{xmodmap} bindings and rules.") > > Please expand the description a bit. > Done. --=20 Best regards, conses From debbugs-submit-bounces@debbugs.gnu.org Thu Mar 16 17:44:06 2023 Received: (at 62101) by debbugs.gnu.org; 16 Mar 2023 21:44:06 +0000 Received: from localhost ([127.0.0.1]:43226 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pcvOI-0007Sm-BS for submit@debbugs.gnu.org; Thu, 16 Mar 2023 17:44:06 -0400 Received: from eggs.gnu.org ([209.51.188.92]:40926) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pcvOG-0007S9-KF for 62101@debbugs.gnu.org; Thu, 16 Mar 2023 17:44:05 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcvO9-0005Mp-78; Thu, 16 Mar 2023 17:43:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=6nomxnrDxZ+/erlWfQp4Wz8Gex1/YR1mf6gcQuQhvUA=; b=RhQDYF2Eqiwr4nBaMhjw 0lP0WKvaEoZkthvvwnrCvKU58/ZQ24z5xsr90YbMukWVvCOcnKVSHukMg9zhbo7losMBQPPh+RFy3 KEQ1j2WKmVl545O4t9Ta4mo1PZLExjQJbsTKArI0Gy/AtDHMoO+e7S5CHTgAP4R9I3qfaiFYqrQC7 fVe7uwXQBSZpPoDI8uazJkDf5uow8L9lyyZM0HFrCaI1ISNPWgWvf+yC0wl9/J6pGY5se/1iSMNCC U/4/nbSALayAFLq8nCh/1/JDw6QUYXufx5swBx79bOFkCNv8Rny5kPqXf60SjF5NQFV1kbuQyzwO/ A8k5io/nqRPBXA==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcvO6-0001cC-TJ; Thu, 16 Mar 2023 17:43:56 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: conses Subject: Re: bug#62101: [PATCH] home: services: Add xmodmap. References: <867cvo9y6b.fsf@conses.eu> <86edpox2zd.fsf@conses.eu> Date: Thu, 16 Mar 2023 22:43:52 +0100 In-Reply-To: <86edpox2zd.fsf@conses.eu> (conses's message of "Thu, 16 Mar 2023 14:03:34 +0100") Message-ID: <87r0to9xt3.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 62101 Cc: 62101@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi, conses skribis: > * gnu/home/services/desktop.scm (home-xmodmap-service-type) > (home-xmodmap-configuration): New variables; > (xmodmap-shepherd-service) > (get-xmodmap-configuration) > (get-xmodmap-file) > (add-xmodmap-config-file) > (add-xmodmap-package): New procedures; > * doc/guix.texi (Desktop Services): Document it. Overall LGTM, with minor issues: > +The syntax for the expression grammar is quite straightforward. You can > +either provide a list of cons cells and strings like this: I=E2=80=99d suggest avoiding the first sentence, because what looks straightforward to someone might be intimidating to another. We also avoid jargon like =E2=80=9Ccons cell=E2=80=9D in the manual. What about something like this: The @code{key-map} field takes a list of objects, each of which is either a @dfn{statement} (a string) or an @dfn{assignment} (a pair of strings). As an example, the snippet below configures the @kbd{mod4} key (???) such that it does XYZ, FIXME: finish sentence :-) =E2=80=A6 where =E2=80=98key-map=E2=80=99 is IMO a better name for =E2=80= =98config=E2=80=99. > +Alternatively, there is a more Lisp-like configuration syntax via Scheme > +symbols, lists, and vectors, that you can use like this: > + > +@lisp > +(service home-xmodmap-service-type > + (home-xmodmap-configuration > + (config '((#(add mod4) . Print) > + (clear lock) I don=E2=80=99t find it very useful; I=E2=80=99d rather support only one sy= ntax, but clearly explained. So my suggestion would be to drop this. > +@item @code{config} (default: @code{config}) (type: list) So this would be renamed to @code{key-map} maybe. > +(define (get-xmodmap-configuration field-name val) As a rule of thumb, you can drop =E2=80=98get-=E2=80=99 from procedure name= s; procedures like this one are rarely called =E2=80=98get-SOMETHING=E2=80=99. > + (service-extension home-profile-service-type > + add-xmodmap-package) I believe this extension is unnecessary. Could you send an updated patch? Thank you! Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Fri Mar 17 08:06:51 2023 Received: (at 62101) by debbugs.gnu.org; 17 Mar 2023 12:06:51 +0000 Received: from localhost ([127.0.0.1]:43878 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pd8rD-0007dy-34 for submit@debbugs.gnu.org; Fri, 17 Mar 2023 08:06:51 -0400 Received: from relay2-d.mail.gandi.net ([217.70.183.194]:54125) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pd8r5-0007dT-ND for 62101@debbugs.gnu.org; Fri, 17 Mar 2023 08:06:44 -0400 Received: (Authenticated sender: contact@conses.eu) by mail.gandi.net (Postfix) with ESMTPSA id 3136740005; Fri, 17 Mar 2023 12:06:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=conses.eu; s=gm1; t=1679054797; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=njWQ9NVDmR4GteL/0X8gUFQeAqoVYUYveBPpKIwRpcg=; b=SVT4yprmAKEAc0m69QEiPYifjVHHIK69zghCzMrp3iD9jj0W+IHe6T04x4SpfIvJELDSbW 9AATQJGmfKVBnOVhY4u7VcXPsIXXftPDghWbKlROqKyaxvJBJj+cNOHVupsqHt+cOeovN7 hn1Sbcoo7A2PP63MY0x7Wuvx+qEAcBNE/PJZMX+00/fX38ZSQOvww/04EhGDaCyJAN+VZ9 kjarIGKmsHaCqq7hyuzGUWvO+d5rpEMNgAh4A25EDePlp1bZkj2BcKqQ8zHMcV6M5eyOho 5RSqMu1f20ZUU0ggZCZa0OB1o5g1VPDiTcYtftd+q31f1ssanvt1gsYF7/JIOg== From: conses To: =?utf-8?Q?Ludovic_Court=C3=A8s?= Subject: [PATCH v3] home: services: Add home-xmodmap-service-type. Date: Fri, 17 Mar 2023 13:06:35 +0100 Message-ID: <863563oa44.fsf@conses.eu> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 62101 Cc: contact@conses.eu, 62101@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) * gnu/home/services/desktop.scm (home-xmodmap-service-type) (home-xmodmap-configuration): New variables; (serialize-xmodmap-configuration) (xmodmap-shepherd-service): New procedures; * doc/guix.texi (Desktop Services): Document it. --- - Tweak manual as per latest comments. - Remove profile and xdg-configuration-file service extensions. - config -> key-map in home-xmodmap-configuration. doc/guix.texi | 41 +++++++++++++++++++++++++ gnu/home/services/desktop.scm | 57 +++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) diff --git a/doc/guix.texi b/doc/guix.texi index aa98d7df4b..baa5fb5ea5 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -42587,6 +42587,47 @@ Desktop Home Services @end deftp +@defvar home-xmodmap-service-type +This is the service type for the +@uref{https://gitlab.freedesktop.org/xorg/app/xmodmap,xmodmap} utility +to modify keymaps and pointer button mappings under the Xorg display +server. Its associated value must be a +@code{home-xmodmap-configuration} record, as shown below. + +The @code{key-map} field takes a list of objects, each of which is +either a @dfn{statement} (a string) or an @dfn{assignment} (a pair of +strings). As an example, the snippet below swaps around the +@kbd{Caps_Lock} and the @kbd{Control_L} keys, by first removing the +keysyms (on the right-hand side) from the corresponding modifier maps +(on the left-hand side), re-assigning them by swapping each other out, +and finally adding back the keysyms to the modifier maps. + +@lisp +(service home-xmodmap-service-type + (home-xmodmap-configuration + (key-map '(("remove Lock" . "Caps_Lock") + ("remove Control" . "Control_L") + ("keysym Control_L" . "Caps_Lock") + ("keysym Caps_Lock" . "Control_L") + ("add Lock" . "Caps_Lock") + ("add Control" . "Control_L"))))) +@end lisp +@end defvar + +@deftp {Data Type} home-xmodmap-configuration +The configuration record for @code{home-xmodmap-service-type}. Its +available fields are: + +@table @asis +@item @code{xmodmap} (default: @code{xmodmap}) (type: file-like) +The @code{xmodmap} package to use. + +@item @code{key-map} (default: @code{'()}) (type: list) +The list of expressions to be read by @code{xmodmap} on service startup. + +@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 ab2b871539..fb1cd44060 100644 --- a/gnu/home/services/desktop.scm +++ b/gnu/home/services/desktop.scm @@ -24,6 +24,7 @@ (define-module (gnu home services desktop) #:use-module (gnu services configuration) #:autoload (gnu packages glib) (dbus) #:autoload (gnu packages xdisorg) (redshift unclutter) + #:autoload (gnu packages xorg) (setxkbmap xmodmap) #:use-module (guix records) #:use-module (guix gexp) #:use-module (srfi srfi-1) @@ -275,3 +276,59 @@ (define home-unclutter-service-type (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."))) + + +;;; +;;; Xmodmap. +;;; + +(define-configuration/no-serialization home-xmodmap-configuration + (xmodmap + (file-like xmodmap) + "The @code{xmodmap} package to use.") + (key-map + (list '()) + "List of expressions to be read by @code{xmodmap} on service startup.")) + +(define (serialize-xmodmap-configuration field-name val) + (define serialize-field + (match-lambda + ((key . value) + (format #f "~a = ~a" key value)) + (e e))) + + #~(string-append + #$@(interpose (map serialize-field val) "\n" 'suffix))) + +(define (xmodmap-shepherd-service config) + (define config-file + (mixed-text-file + "config" + (serialize-xmodmap-configuration + #f (home-xmodmap-configuration-key-map config)))) + + (list + (shepherd-service + (provision '(xmodmap)) + (start #~(make-system-constructor + (string-join + (list #$(file-append + (home-xmodmap-configuration-xmodmap config) + "/bin/xmodmap") + #$config-file)))) + (stop #~(make-system-constructor + #$(file-append setxkbmap "/bin/setxkbmap"))) + (documentation "On startup, run @code{xmodmap} and read the expressions in +the configuration file. On stop, reset all the mappings back to the +defaults.")))) + +(define home-xmodmap-service-type + (service-type + (name 'home-xmodmap) + (extensions + (list + (service-extension home-shepherd-service-type + xmodmap-shepherd-service))) + (default-value (home-xmodmap-configuration)) + (description "Run the @code{xmodmap} utility to modify keymaps and pointer +buttons under the Xorg display server via user-defined expressions."))) -- 2.39.1 -- Best regards, conses From debbugs-submit-bounces@debbugs.gnu.org Fri Mar 17 17:50:50 2023 Received: (at 62101-done) by debbugs.gnu.org; 17 Mar 2023 21:50:50 +0000 Received: from localhost ([127.0.0.1]:45812 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pdHyL-0001wZ-VM for submit@debbugs.gnu.org; Fri, 17 Mar 2023 17:50:50 -0400 Received: from eggs.gnu.org ([209.51.188.92]:40914) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pdHyJ-0001wK-MS for 62101-done@debbugs.gnu.org; Fri, 17 Mar 2023 17:50:48 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pdHyD-0004RX-OZ; Fri, 17 Mar 2023 17:50:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=yTf7jdlm5Fqv01KlNVxmznUpEhDtomMXc8aSa8U/BUg=; b=m44o+VRG6FBoGBZgxy0q 3GpE9wKeZ7YFFzVHJi8mSdT87V/+TXkMTgbm8RsaRkoQwyXSE0OKAkBbZ+lC4Kzb/ugXelo9VCeOU Crt/1T224c1yyDvMXQ6dHi9SorJvB6SEAeLUtVa8VyXs6NcfBleTGDMFnkg4f+RYTn8aiA8g9nBQc mz4WckXO51cRBrn7oibQY+f7w2xMYmSs3ahJog/mdcIam9IZJCGnn7heWueZ7jn1gyNrmY0EOG3y1 m5DUbA+Pn3XwvjXIzi3iSnSs3GPNk+PuR04dClXw02dTC2iGSO3sf8KUkCAvCqzDRR1c2ZU3qwePC qc9Zu0WyXyRzSQ==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pdHyD-0007BJ-8p; Fri, 17 Mar 2023 17:50:41 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: conses Subject: Re: [PATCH v3] home: services: Add home-xmodmap-service-type. References: <863563oa44.fsf@conses.eu> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: Septidi 27 =?utf-8?Q?Vent=C3=B4se?= an 231 de la =?utf-8?Q?R=C3=A9volution=2C?= jour de la Sylvie X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Fri, 17 Mar 2023 22:50:39 +0100 In-Reply-To: <863563oa44.fsf@conses.eu> (conses's message of "Fri, 17 Mar 2023 13:06:35 +0100") Message-ID: <877cvfvyhc.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 62101-done Cc: 62101-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi, conses skribis: > * gnu/home/services/desktop.scm (home-xmodmap-service-type) > (home-xmodmap-configuration): New variables; > (serialize-xmodmap-configuration) > (xmodmap-shepherd-service): New procedures; > * doc/guix.texi (Desktop Services): Document it. Applied, thank you! Ludo=E2=80=99. From unknown Mon Jun 23 07:50:01 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 15 Apr 2023 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator