From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.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 oOi1AtsTE2R0XwAASxT56A (envelope-from ) for ; Thu, 16 Mar 2023 14:04:27 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id sENaAtsTE2RGHgEAauVa8A (envelope-from ) for ; Thu, 16 Mar 2023 14:04:27 +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 95FD227618 for ; Thu, 16 Mar 2023 14:04:26 +0100 (CET) Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=conses.eu header.s=gm1 header.b="a1/QRAok"; dmarc=none; 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" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1678971866; 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=0++0oWJxtxz2RK0NRP4AsC5gDXyjd/mgehbPwsVc3MU=; b=o2bJTKP1eLqM+IHxdFRyKhfJW3iLH/Epv4KZW3nmZkZ6USGCEtiHwC0g3rI+e/4QFKALG+ qiVkdi9v1aJzx25lQHQ0s38hS5SG4S/FO4LlErROh2V60NNl0yRYWoH205aG1EoIlLPC4D FOTVcDlwQRZv8vM+pMuqXoLGUCmPm1AWq3l4pqf/7hNVrlR7cH63W4vuVCW3z5/WTwMmOD Ax4ywJYuoGdN8PmP71RSieF8VT3bnH+ViKDoIDoThzvu6wo+lM/2TzxRNBjDf5TsTG8QaJ Uz2qn+yNDU0P7fxh4ELQ9mx1II0vHERUbIZ/h+PeRWcgXTEpfNuMN7kUfRB9Xg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=conses.eu header.s=gm1 header.b="a1/QRAok"; dmarc=none; 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" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1678971866; a=rsa-sha256; cv=none; b=GHP8F4J7dKXMzMbiAiREDS+Gy8fiIizUGU4bFlROWD6mICjbAQRi8G2c/60TsnfliOmvfo zTCKB0MPWIzUgadcBNYgGLAy6tCJYM2fcUap7jwkasX4jt7Dzk2NCiLZnrrAwFtZvh5pyn UZtsRh3YS6L4KIG7MxHlCq8IGmENo5wTsydQzbYgStIfgbfXEIhy+pGSYx9uqRZmPbfkgP H9fox53RvFVCGXYpadqJnVxO1vCN4ZBbkTe/oZk21NtWGYloPjyK7Ll34I/54/vpjRfwIU PX+EYiT6AeyOgdIJiIowZvlh+f/2i1EYr5s6B8t0G1JqCHsdc283xjzVuG+OmA== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pcnH3-00051I-0o; Thu, 16 Mar 2023 09:04:05 -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 1pcnH0-00050h-Vd for guix-patches@gnu.org; Thu, 16 Mar 2023 09:04:03 -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 1pcnH0-0004Iu-N5 for guix-patches@gnu.org; Thu, 16 Mar 2023 09:04:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pcnH0-0007Qy-85 for guix-patches@gnu.org; Thu, 16 Mar 2023 09:04:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#62101] [PATCH v2] 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: Thu, 16 Mar 2023 13:04: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.167897182628551 (code B ref 62101); Thu, 16 Mar 2023 13:04:02 +0000 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 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-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: X-Migadu-Queue-Id: 95FD227618 X-Spam-Score: -2.64 X-Migadu-Spam-Score: -2.64 X-Migadu-Scanner: scn0.migadu.com 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 X-TUID: kgAbbejpZ2ET * 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