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 YIbhABWMC2TaYwAASxT56A (envelope-from ) for ; Fri, 10 Mar 2023 20:59:17 +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 UCyrABWMC2TSXwEAauVa8A (envelope-from ) for ; Fri, 10 Mar 2023 20:59:17 +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 2E41B19944 for ; Fri, 10 Mar 2023 20:59:16 +0100 (CET) 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 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-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=KWkU7L5V; 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=1678478356; a=rsa-sha256; cv=none; b=hyMtMzzUQPifASXVYhUdsXaGlWd+2qs82foETiEUdPl8YpU5iAUkoWgdqWKG3C5Z4BqFmI QOfA6uSpQIC0updeL1SY7DLetSDDjFH73xwXjyogjVKJEZeuqGeWOqkIev9otOcSLmjg+h Y+tz1al/Lio37YXa/7PItC9EBTR2p6l1gVXr44xPAWk4TcP/T0AcmM++Q4ACKp4MCysTEE CN6MOMqgevklprH550TqdE5diyKezUY0vQCm1xOFkfJx3ai11hoPF/KZiqajchHHxPUdXV kabr7WOj25cq+VHxnrXgIdetTXpa6t48a2Oj4l+QxPnoUb3ndNTI5DPielURUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1678478356; 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:list-id:list-help:list-unsubscribe:list-subscribe: list-post:dkim-signature; bh=HiC8CJnn1Z4Gk7bduk1B10PKxdivXuoTDS/TUzCP5B0=; b=fjTRmKbeWGTJ/RMzB0jJM+yfLfVtY62knDwwENUD4KyjOCB50M9pJ6VWmI0b8iAIyut1ef MaoH2tVvjc+9o/I4+CzvyFBPW/toqS3LIRvXaEDxpT9dQ5LXSSq8B75jeWUXLz/XrE3Zx+ t5Ak6MEsEJKC6BiD7Su1iLr0oSfyDNWTTBAPlPQnVVIw9MFVM4uktRkVT6VrynuK+VV8Vf 3l78pYDO9+mnKPp29hWtVc8fblkBpRXPlET1NuIxuVGzGMqjfJV1whXdekI2APl5DcjblW njI9KmpSHpEQQPDwFG/wd9rqCMf3T1ID/iCjSZzA1j/wIqT0bBOxbzesPI1+JA== X-Migadu-Spam-Score: -2.50 X-Spam-Score: -2.50 X-Migadu-Queue-Id: 2E41B19944 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=KWkU7L5V; 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: 5jbvCj2CIPtw --- 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