From patchwork Wed Mar 20 23:04:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 1513 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 AC68A16DB6; Wed, 20 Mar 2019 23:06:17 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id 50C3F16DB4 for ; Wed, 20 Mar 2019 23:06:17 +0000 (GMT) Received: from localhost ([127.0.0.1]:56186 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6kHm-0007sC-Hp for patchwork@mira.cbaines.net; Wed, 20 Mar 2019 19:06:14 -0400 Received: from eggs.gnu.org ([209.51.188.92]:43150) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6kHe-0007rn-AZ for guix-patches@gnu.org; Wed, 20 Mar 2019 19:06:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6kHd-0003PI-0s for guix-patches@gnu.org; Wed, 20 Mar 2019 19:06:06 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:38917) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h6kHc-0003P9-OM for guix-patches@gnu.org; Wed, 20 Mar 2019 19:06:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1h6kHc-0005hz-Hk for guix-patches@gnu.org; Wed, 20 Mar 2019 19:06:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#34929] [PATCH 08/12] services: xorg: Add a 'keyboard-layout' field in . Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 20 Mar 2019 23:06:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34929 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 34929@debbugs.gnu.org Received: via spool by 34929-submit@debbugs.gnu.org id=B34929.155312310721813 (code B ref 34929); Wed, 20 Mar 2019 23:06:04 +0000 Received: (at 34929) by debbugs.gnu.org; 20 Mar 2019 23:05:07 +0000 Received: from localhost ([127.0.0.1]:52451 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h6kGh-0005fe-B3 for submit@debbugs.gnu.org; Wed, 20 Mar 2019 19:05:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:56823) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h6kGZ-0005d6-TC for 34929@debbugs.gnu.org; Wed, 20 Mar 2019 19:05:00 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:36737) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6kGU-0002SH-L4; Wed, 20 Mar 2019 19:04:54 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=57670 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1h6kGU-0004wC-0U; Wed, 20 Mar 2019 19:04:54 -0400 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Thu, 21 Mar 2019 00:04:31 +0100 Message-Id: <20190320230435.25458-8-ludo@gnu.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190320230435.25458-1-ludo@gnu.org> References: <20190320230435.25458-1-ludo@gnu.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nee Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * gnu/services/xorg.scm ()[keyboard-layout]: New field. (xorg-configuration->file)[input-class-section]: New procedure. Use it. * doc/guix.texi (X Window): Document 'keyboard-layout' field. Co-authored-by: nee --- doc/guix.texi | 8 ++++++++ gnu/services/xorg.scm | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/doc/guix.texi b/doc/guix.texi index 6b73225697..5fa68d5e5a 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -13332,6 +13332,14 @@ When @code{resolutions} is the empty list, Xorg chooses an appropriate screen resolution. Otherwise, it must be a list of resolutions---e.g., @code{((1024 768) (640 480))}. +@cindex keyboard layout, for Xorg +@item @code{keyboard-layout} (default: @code{#f}) +If this is @code{#f}, Xorg uses the default keyboard layout---usually US +English (``qwerty'') for a 105-key PC keyboard. + +Otherwise this must be a @code{keyboard-layout} object specifying the keyboard +layout in use when Xorg is running. + @item @code{extra-config} (default: @code{'()}) This is a list of strings or objects appended to the configuration file. It is used to pass extra text to be added verbatim to the configuration file. diff --git a/gnu/services/xorg.scm b/gnu/services/xorg.scm index a3a4d769d7..05465f3bdf 100644 --- a/gnu/services/xorg.scm +++ b/gnu/services/xorg.scm @@ -25,6 +25,7 @@ #:use-module (gnu services) #:use-module (gnu services shepherd) #:use-module (gnu system pam) + #:use-module (gnu system keyboard) #:use-module (gnu services dbus) #:use-module ((gnu packages base) #:select (canonical-package)) #:use-module (gnu packages guile) @@ -147,6 +148,8 @@ (default '())) (resolutions xorg-configuration-resolutions ;list of tuples (default '())) + (keyboard-layout xorg-configuration-keyboard-layout ;#f | + (default #f)) (extra-config xorg-configuration-extra-config ;list of strings (default '())) (server xorg-configuration-server ;package @@ -195,6 +198,31 @@ Section \"Screen\" EndSubSection EndSection")) + (define (input-class-section layout variant model options) + (string-append " +Section \"InputClass\" + Identifier \"evdev keyboard catchall\" + MatchIsKeyboard \"on\" + Option \"XkbLayout\" " (object->string layout) + (if variant + (string-append " Option \"XkbVariant\" \"" + variant "\"") + "") + (if model + (string-append " Option \"XkbModel\" \"" + model "\"") + "") + (match options + (() + "") + (_ + (string-append " Option \"XkbOptions\" \"" + (string-join options ",") "\""))) " + + MatchDevicePath \"/dev/input/event*\" + Driver \"evdev\" +EndSection\n")) + (define (expand modules) ;; Append to MODULES the relevant /lib/xorg/modules ;; sub-directories. @@ -240,6 +268,19 @@ EndSection\n" port) port) (newline port) + (let ((layout #$(and=> (xorg-configuration-keyboard-layout config) + keyboard-layout-name)) + (variant #$(and=> (xorg-configuration-keyboard-layout config) + keyboard-layout-variant)) + (model #$(and=> (xorg-configuration-keyboard-layout config) + keyboard-layout-model)) + (options '#$(keyboard-layout-options + (xorg-configuration-keyboard-layout config)))) + (when layout + (display (input-class-section layout variant model options) + port) + (newline port))) + (for-each (lambda (config) (display config port)) '#$(xorg-configuration-extra-config config))))))