From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id oCV+GwNYFGQcdgAASxT56A (envelope-from ) for ; Fri, 17 Mar 2023 13:07:31 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id 4PCLGwNYFGS+sAAA9RJhRA (envelope-from ) for ; Fri, 17 Mar 2023 13:07:31 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 13F528C8A for ; Fri, 17 Mar 2023 13:07:30 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pd8rV-0002TI-99; Fri, 17 Mar 2023 08:07:09 -0400 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 1pd8rQ-0002S1-0X for guix-patches@gnu.org; Fri, 17 Mar 2023 08:07:05 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pd8rO-0004tc-NN for guix-patches@gnu.org; Fri, 17 Mar 2023 08:07:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pd8rO-0007eN-Ah for guix-patches@gnu.org; Fri, 17 Mar 2023 08:07:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#62101] [PATCH v3] home: services: Add home-xmodmap-service-type. References: <867cvo9y6b.fsf@conses.eu> In-Reply-To: <867cvo9y6b.fsf@conses.eu> Resent-From: conses Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 17 Mar 2023 12:07:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62101 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: contact@conses.eu, 62101@debbugs.gnu.org Received: via spool by 62101-submit@debbugs.gnu.org id=B62101.167905481129391 (code B ref 62101); Fri, 17 Mar 2023 12:07:02 +0000 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 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=conses.eu header.s=gm1 header.b=SVT4yprm; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=none ARC-Seal: i=1; s=key1; d=yhetil.org; t=1679054851; a=rsa-sha256; cv=none; b=hRZguI8D+4ZmbYzYUVR21oU3HeJbnRC80sOJogNiSrbYxtuf2vHspoTbfxuIYW0q0U8dI9 /+0WsOJwznBxOt/ki6v4732+FDFf0J+hZHHX926leyCQ+MFh6sK8p7XaRG5hNvzvS0qoVM gTkUzsIhQdtUYKA/zMCV5EBfncfCBbpifhnetU98jHLBrHyx30oHIvw8qVx0UfJ4ak60zA LZkOM2uWlv+jHfanybdAxvSt0KmXh9htsVR3E7NW/16P48qDLbfYPUmGiPsG4O7DpntIm5 dZu9S2J05Yqb+LRS4B2iLyDZy8Ba+j8ne4hh+fsy4RZVaomy3Xbi1ohqCtmdsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1679054851; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=njWQ9NVDmR4GteL/0X8gUFQeAqoVYUYveBPpKIwRpcg=; b=p+tYyZZxZTe9YWaa5MdkYWiUYQj4GOSEyxmq6Hv7FmEMZ0rncVKnm/Rh6R5Mmfcwy2qRer 3ZkFBern3WwZF76V5LpLvoyI139U08AFA2Dan3NlCXU2uZBzJERE5tOw98aQRfjrf4gDAi I7JsbbWl/UPBbhu18HURaG6kpgjdPy68n88c15AuBwHWgplh8mqqnvlSQsU7tt4j+nKOYz 9KJdacvOPxQmCaT9gkEjDBA6ono+JKiz5JV65SG2y86rHjpABuq9pDdMaqTTwVHsfwoHfB BbqieyuSXQURJEMFHwRbg0J/fRTnYelMJiBFrQ3I1XoCt7AFVqVFwcU+uiSWDQ== X-Migadu-Spam-Score: -2.34 X-Spam-Score: -2.34 X-Migadu-Queue-Id: 13F528C8A X-Migadu-Scanner: scn1.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=conses.eu header.s=gm1 header.b=SVT4yprm; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=none X-TUID: +eiWZpm5bQBj * 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