From patchwork Fri Mar 10 19:57:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Miguel_=C3=81ngel_Moreno?= X-Patchwork-Id: 47854 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 9474016E84; Fri, 10 Mar 2023 19:59:18 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 3822816E7D for ; Fri, 10 Mar 2023 19:59:16 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1paitO-0007Pe-K0; Fri, 10 Mar 2023 14:59:06 -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 1paitM-0007Nu-JY for guix-patches@gnu.org; Fri, 10 Mar 2023 14:59:04 -0500 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 1paitK-0005uK-Ur for guix-patches@gnu.org; Fri, 10 Mar 2023 14:59:04 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1paitK-000858-EO for guix-patches@gnu.org; Fri, 10 Mar 2023 14:59:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#62101] [PATCH] home: services: Add xmodmap. Resent-From: conses Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 10 Mar 2023 19:59:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 62101 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 62101@debbugs.gnu.org Cc: contact@conses.eu, Andrew Tropin X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.167847828330897 (code B ref -1); Fri, 10 Mar 2023 19:59:02 +0000 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 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 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-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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches --- 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))