all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: 34929@debbugs.gnu.org
Cc: nee <nee-git@hidamari.blue>
Subject: [bug#34929] [PATCH 08/12] services: xorg: Add a 'keyboard-layout' field in <xorg-configuration>.
Date: Thu, 21 Mar 2019 00:04:31 +0100	[thread overview]
Message-ID: <20190320230435.25458-8-ludo@gnu.org> (raw)
In-Reply-To: <20190320230435.25458-1-ludo@gnu.org>

* gnu/services/xorg.scm (<xorg-configuration>)[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 <nee-git@hidamari.blue>
---
 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 | <keyboard-layout>
+                    (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))))))
-- 
2.21.0

  parent reply	other threads:[~2019-03-20 23:06 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-20 22:32 [bug#34929] [PATCH 00/12] Provide uniform keyboard layout configuration Ludovic Courtès
2019-03-20 23:04 ` [bug#34929] [PATCH 01/12] bootloader: Remove unused 'additional-configuration' field Ludovic Courtès
2019-03-20 23:04   ` [bug#34929] [PATCH 02/12] bootloader: Reindent record type definition Ludovic Courtès
2019-03-20 23:04   ` [bug#34929] [PATCH 03/12] Add (gnu system keyboard) Ludovic Courtès
2019-03-20 23:04   ` [bug#34929] [PATCH 04/12] bootloader: Add a 'keyboard-layout' field Ludovic Courtès
2019-03-24  9:31     ` Julien Lepiller
2019-03-24 21:18       ` Ludovic Courtès
2019-03-20 23:04   ` [bug#34929] [PATCH 05/12] services: xorg: Remove unused #:guile parameter Ludovic Courtès
2019-03-20 23:04   ` [bug#34929] [PATCH 06/12] services: xorg: Define and <xorg-configuration> record type Ludovic Courtès
2019-03-24  9:46     ` Julien Lepiller
2019-03-24 21:18       ` Ludovic Courtès
2019-03-20 23:04   ` [bug#34929] [PATCH 07/12] services: sddm, slim, gdm: Take an <xorg-configuration> record Ludovic Courtès
2019-03-20 23:04   ` Ludovic Courtès [this message]
2019-03-24  9:50     ` [bug#34929] [PATCH 08/12] services: xorg: Add a 'keyboard-layout' field in <xorg-configuration> Julien Lepiller
2019-03-20 23:04   ` [bug#34929] [PATCH 09/12] vm: 'virtualized-operating-system' inherits from the user's bootloader config Ludovic Courtès
2019-03-20 23:04   ` [bug#34929] [PATCH 10/12] gnu: Add loadkeys-static Ludovic Courtès
2019-03-20 23:04   ` [bug#34929] [PATCH 11/12] system: Initialize console keyboard layout in the initrd Ludovic Courtès
2019-03-20 23:04   ` [bug#34929] [PATCH 12/12] doc: Document keyboard layout Ludovic Courtès
2019-03-24 10:03 ` [bug#34929] [PATCH 00/12] Provide uniform keyboard layout configuration Julien Lepiller
2019-03-24 22:14   ` bug#34929: " Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190320230435.25458-8-ludo@gnu.org \
    --to=ludo@gnu.org \
    --cc=34929@debbugs.gnu.org \
    --cc=nee-git@hidamari.blue \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.