diff mbox series

[bug#47994] services: kmscon: Add xkb-layout and xkb-options fields.

Message ID YIOulQzN9Rs12Kk7@thinkpad-x230-luhui
State Accepted
Headers show
Series [bug#47994] services: kmscon: Add xkb-layout and xkb-options fields. | expand

Checks

Context Check Description
cbaines/submitting builds success
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue

Commit Message

luhui April 24, 2021, 5:37 a.m. UTC
Added xkb-layout and xkb-options fields to adjust the keyboard layout of kmscon
From 02ae9ab208f83974eac92dcbeb74091b0670cef7 Mon Sep 17 00:00:00 2001
From: luhui <luhuins@163.com>
Date: Sat, 24 Apr 2021 10:56:03 +0800
Subject: [PATCH] services: kmscon: Add xkb-layout and xkb-options fields.

* gnu/services/base.scm (<kmscon-configuration>): Add xkb-layout and
xkb-options fields.
* doc/guix.texi (Base Services): Document them.

Signed-off-by: luhui <luhuins@163.com>
---
 doc/guix.texi         |  6 ++++++
 gnu/services/base.scm | 12 ++++++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)

Comments

M April 25, 2021, 9:12 a.m. UTC | #1
luhui schreef op za 24-04-2021 om 13:37 [+0800]:

> @item @code{xkb-layout} (default: @code{#f})
> Keyboard layout used in Kmscon.

What is the default here, is this a package object, a file-like object,
a string, where can I find a list of keyboard layouts ... please document!

> @item @code{xkb-options} (default: @code{#f})
> Keyboard layout options used in Kmscon.

What are the possible options, is this a list, a string, a list of strings, ...
please document!

> Signed-off-by: luhui <luhuins@163.com>

Guix uses Signed-off-by differently from LKML.  IIUC, Signed-off-by is used when committing
on behalf of someone else, and is added by the committer.  The line would be something like

  Signed-off-by: Some Guix Committer <mail@example.org>

As you added a few things to doc/guix.texi and gnu/services/base.scm, you
can add a copyright line there.

Otherwise, I don't see any obvious problems, but I haven't tested.

Greetings,
Maxime.
M April 25, 2021, 12:46 p.m. UTC | #2
luhui schreef op zo 25-04-2021 om 18:04 [+0800]:
> +@item @code{xkb-layout} (default: @code{#f})
> +When true, this field be a string used for set keyboard layout used in Kmscon.
> +See the @code{xkeyboard-config} package for valid layouts.
> +
> +@item @code{xkb-options} (default: @code{#f})
> +When true, this field be a string used for set keyboard layout options used in
> +Kmscon. See the @code{xkeyboard-config} package for valid options.

I looked in the guix manual for ideas how to formulate this clearer.
The section ‘10.6 Keyboard layout’ (<https://guix.gnu.org/manual/en/html_node/Keyboard-Layout.html#Keyboard-Layout>)
seems interesting, in particualr the "keyboard-layout" procedure from (gnu system keyboard).
It seemed a nicer abstraction than just raw strings.

An extract from the manual:

   Keyboard layouts are represented by records created by the
‘keyboard-layout’ procedure of ‘(gnu system keyboard)’.  Following the X
Keyboard extension (XKB), each layout has four attributes: a name (often
a language code such as “fi” for Finnish or “jp” for Japanese), an
optional variant name, an optional keyboard model name, and a possibly
empty list of additional options.  In most cases the layout name is all
you care about.

 -- Scheme Procedure: keyboard-layout NAME [VARIANT] [#:model]
          [#:options '()]
     Return a new keyboard layout with the given NAME and VARIANT.

     NAME must be a string such as ‘"fr"’; VARIANT must be a string such
     as ‘"bepo"’ or ‘"nodeadkeys"’.  See the ‘xkeyboard-config’ package
     for valid options.

   Here are a few examples:

     ;; The German QWERTZ layout.  Here we assume a standard
     ;; "pc105" keyboard model.
     (keyboard-layout "de")

     ;; The bépo variant of the French layout.
     (keyboard-layout "fr" "bepo")

Could this be used instead of raw strings?


> +When true, this field be a string used for set keyboard layout used in Kmscon.

When true, this field is a string representing the name of the keyboard layout.
Suggested documentation (based on the xorg-configuration documentation):

@item @code{keboard-layout} (default: @code{#f})
If this is false, Kmscon uses the default keyboard layout.

Otherwise this must be a field is a ‘keyboard layout’ object specifying
the keyboard layout to use for the console.   *Note
          Keyboard Layout::, for more information on how to specify the
keyboard layout.

Greetings,
Maxime.
diff mbox series

Patch

diff --git a/doc/guix.texi b/doc/guix.texi
index b9019d5550..e92c57e84c 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -15254,6 +15254,12 @@  Font engine used in Kmscon.
 @item @code{font-size} (default: @code{12})
 Font size used in Kmscon.
 
+@item @code{xkb-layout} (default: @code{#f})
+Keyboard layout used in Kmscon.
+
+@item @code{xkb-options} (default: @code{#f})
+Keyboard layout options used in Kmscon.
+
 @item @code{kmscon} (default: @var{kmscon})
 The Kmscon package to use.
 
diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index 24b3ea785b..2c442416b7 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -2313,7 +2313,11 @@  This service is not part of @var{%base-services}."
   (font-engine             kmscon-configuration-font-engine
                            (default "pango"))
   (font-size               kmscon-configuration-font-size
-                           (default 12)))
+                           (default 12))
+  (xkb-layout              kmscon-configuration-xkb-layout
+                           (default #f))
+  (xkb-options             kmscon-configuration-xkb-options
+                           (default #f)))
 
 (define kmscon-service-type
   (shepherd-service-type
@@ -2326,7 +2330,9 @@  This service is not part of @var{%base-services}."
            (auto-login (kmscon-configuration-auto-login config))
            (hardware-acceleration? (kmscon-configuration-hardware-acceleration? config))
            (font-engine (kmscon-configuration-font-engine config))
-           (font-size (kmscon-configuration-font-size config)))
+           (font-size (kmscon-configuration-font-size config))
+           (xkb-layout (kmscon-configuration-xkb-layout config))
+           (xkb-options (kmscon-configuration-xkb-options config)))
 
        (define kmscon-command
          #~(list
@@ -2335,6 +2341,8 @@  This service is not part of @var{%base-services}."
             "--no-switchvt" ;Prevent a switch to the virtual terminal.
             "--font-engine" #$font-engine
             "--font-size" #$(number->string font-size)
+            #$@(if xkb-layout (list "--xkb-layout" xkb-layout) '())
+            #$@(if xkb-options (list "--xkb-options" xkb-options) '())
             #$@(if hardware-acceleration? '("--hwaccel") '())
             "--login" "--"
             #$login-program #$@login-arguments