unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / Atom feed
* [bug#47994] [PATCH] services: kmscon: Add xkb-layout and xkb-options fields.
@ 2021-04-24  5:37 luhui
  2021-04-25  9:12 ` Maxime Devos
  0 siblings, 1 reply; 7+ messages in thread
From: luhui @ 2021-04-24  5:37 UTC (permalink / raw)
  To: 47994

[-- Attachment #1: Type: text/plain, Size: 81 bytes --]

Added xkb-layout and xkb-options fields to adjust the keyboard layout of kmscon


[-- Attachment #2: 0001-services-kmscon-Add-xkb-layout-and-xkb-options-field.patch --]
[-- Type: text/plain, Size: 2903 bytes --]

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(-)

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
-- 
2.31.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [bug#47994] [PATCH] services: kmscon: Add xkb-layout and xkb-options fields.
  2021-04-24  5:37 [bug#47994] [PATCH] services: kmscon: Add xkb-layout and xkb-options fields luhui
@ 2021-04-25  9:12 ` Maxime Devos
  2021-04-25 10:04   ` luhui
  0 siblings, 1 reply; 7+ messages in thread
From: Maxime Devos @ 2021-04-25  9:12 UTC (permalink / raw)
  To: luhui, 47994

[-- Attachment #1: Type: text/plain, Size: 975 bytes --]

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.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [bug#47994] [PATCH] services: kmscon: Add xkb-layout and xkb-options fields.
  2021-04-25  9:12 ` Maxime Devos
@ 2021-04-25 10:04   ` luhui
  2021-04-25 12:46     ` Maxime Devos
  0 siblings, 1 reply; 7+ messages in thread
From: luhui @ 2021-04-25 10:04 UTC (permalink / raw)
  To: Maxime Devos; +Cc: 47994, luhui

[-- Attachment #1: Type: text/plain, Size: 15 bytes --]

ok, new patch:

[-- Attachment #2: 0001-services-kmscon-Add-xkb-layout-and-xkb-options-field.patch --]
[-- Type: text/plain, Size: 3772 bytes --]

From 17c626839fb397e8c6f40d2855623f7181d0ab31 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.
---
 doc/guix.texi         |  9 +++++++++
 gnu/services/base.scm | 13 +++++++++++--
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index b9019d5550..e8007c3965 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -88,6 +88,7 @@ Copyright @copyright{} 2020 John Soo@*
 Copyright @copyright{} 2020 Jonathan Brielmaier@*
 Copyright @copyright{} 2020 Edgar Vincent@*
 Copyright @copyright{} 2021 Maxime Devos@*
+Copyright @copyright{} 2021 lu hui@*
 
 Permission is granted to copy, distribute and/or modify this document
 under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -15254,6 +15255,14 @@ Font engine used in Kmscon.
 @item @code{font-size} (default: @code{12})
 Font size used in Kmscon.
 
+@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.
+
 @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..bee101ab29 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -14,6 +14,7 @@
 ;;; Copyright © 2020 Florian Pelz <pelzflorian@pelzflorian.de>
 ;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re>
 ;;; Copyright © 2021 qblade <qblade@protonmail.com>
+;;; Copyright © 2021 luhui <luhuins@163.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -2313,7 +2314,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)) ;string | #f
+  (xkb-options             kmscon-configuration-xkb-options
+                           (default #f))) ;string | #f
 
 (define kmscon-service-type
   (shepherd-service-type
@@ -2326,7 +2331,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 +2342,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
-- 
2.31.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [bug#47994] [PATCH] services: kmscon: Add xkb-layout and xkb-options fields.
  2021-04-25 10:04   ` luhui
@ 2021-04-25 12:46     ` Maxime Devos
  2021-04-26  2:07       ` luhui
  0 siblings, 1 reply; 7+ messages in thread
From: Maxime Devos @ 2021-04-25 12:46 UTC (permalink / raw)
  To: luhui; +Cc: 47994

[-- Attachment #1: Type: text/plain, Size: 2529 bytes --]

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.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [bug#47994] [PATCH] services: kmscon: Add xkb-layout and xkb-options fields.
  2021-04-25 12:46     ` Maxime Devos
@ 2021-04-26  2:07       ` luhui
  2021-04-26 19:23         ` Maxime Devos
  0 siblings, 1 reply; 7+ messages in thread
From: luhui @ 2021-04-26  2:07 UTC (permalink / raw)
  To: Maxime Devos; +Cc: 47994, luhui

[-- Attachment #1: Type: text/plain, Size: 66 bytes --]

OK,Re-written the code according to your suggestion.

new patch:


[-- Attachment #2: 0001-services-kmscon-Add-keyboard-layout-fields.patch --]
[-- Type: text/plain, Size: 4514 bytes --]

From 49450d3f87bebb0eeb5a2d4a161151b33d413c15 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 keyboard-layout fields.

* gnu/services/base.scm (<kmscon-configuration>): Add keyboard-layout fields.
* doc/guix.texi (Base Services): Document it.
---
 doc/guix.texi         |  9 +++++++++
 gnu/services/base.scm | 21 +++++++++++++++++++--
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index b9019d5550..74e9ceaf5e 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -88,6 +88,7 @@ Copyright @copyright{} 2020 John Soo@*
 Copyright @copyright{} 2020 Jonathan Brielmaier@*
 Copyright @copyright{} 2020 Edgar Vincent@*
 Copyright @copyright{} 2021 Maxime Devos@*
+Copyright @copyright{} 2021 lu hui@*
 
 Permission is granted to copy, distribute and/or modify this document
 under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -15254,6 +15255,14 @@ Font engine used in Kmscon.
 @item @code{font-size} (default: @code{12})
 Font size used in Kmscon.
 
+@item @code{keyboard-layout} (default: @code{#f})
+If this is @code{#f}, Kmscon 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. @xref{Keyboard Layout}, for more information on how to specify the
+keyboard layout.
+
 @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..0878746fa8 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -14,6 +14,7 @@
 ;;; Copyright © 2020 Florian Pelz <pelzflorian@pelzflorian.de>
 ;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re>
 ;;; Copyright © 2021 qblade <qblade@protonmail.com>
+;;; Copyright © 2021 luhui <luhuins@163.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -41,6 +42,7 @@
   #:use-module (gnu system shadow)                ; 'user-account', etc.
   #:use-module (gnu system uuid)
   #:use-module (gnu system file-systems)          ; 'file-system', etc.
+  #:use-module (gnu system keyboard)
   #:use-module (gnu system mapped-devices)
   #:use-module ((gnu system linux-initrd)
                 #:select (file-system-packages))
@@ -2313,7 +2315,9 @@ 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))
+  (keyboard-layout         kmscon-configuration-keyboard-layout
+                           (default #f))) ; #f | <keyboard-layout>
 
 (define kmscon-service-type
   (shepherd-service-type
@@ -2326,7 +2330,8 @@ 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))
+           (keyboard-layout (kmscon-configuration-keyboard-layout config)))
 
        (define kmscon-command
          #~(list
@@ -2335,6 +2340,18 @@ 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 keyboard-layout
+                   (let* ((layout (keyboard-layout-name keyboard-layout))
+                          (variant (keyboard-layout-variant keyboard-layout))
+                          (model (keyboard-layout-model keyboard-layout))
+                          (options (keyboard-layout-options keyboard-layout)))
+                     `("--xkb-layout" ,layout
+                       ,@(if variant `("--xkb-layout" ,variant) '())
+                       ,@(if model   `("--xkb-model" ,model) '())
+                       ,@(if (null? options)
+                             '()
+                             `("--xkb-options" ,(string-join options ",")))))
+                   '())
             #$@(if hardware-acceleration? '("--hwaccel") '())
             "--login" "--"
             #$login-program #$@login-arguments
-- 
2.31.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [bug#47994] [PATCH] services: kmscon: Add xkb-layout and xkb-options fields.
  2021-04-26  2:07       ` luhui
@ 2021-04-26 19:23         ` Maxime Devos
  2021-05-04 11:32           ` luhui
  0 siblings, 1 reply; 7+ messages in thread
From: Maxime Devos @ 2021-04-26 19:23 UTC (permalink / raw)
  To: luhui; +Cc: 47994

[-- Attachment #1: Type: text/plain, Size: 207 bytes --]

luhui schreef op ma 26-04-2021 om 10:07 [+0800]:
> OK,Re-written the code according to your suggestion.
> 
> new patch:

The new patch looks good to me, but I haven't tested it.

Greetings,
Maxime.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [bug#47994] [PATCH] services: kmscon: Add xkb-layout and xkb-options fields.
  2021-04-26 19:23         ` Maxime Devos
@ 2021-05-04 11:32           ` luhui
  0 siblings, 0 replies; 7+ messages in thread
From: luhui @ 2021-05-04 11:32 UTC (permalink / raw)
  To: Maxime Devos; +Cc: 47994, luhui

On Mon, Apr 26, 2021 at 09:23:00PM +0200, Maxime Devos wrote:
> luhui schreef op ma 26-04-2021 om 10:07 [+0800]:
> > OK,Re-written the code according to your suggestion.
> > 
> > new patch:
> 
> The new patch looks good to me, but I haven't tested it.


write it in a vm configuration

test code:

#+BEGIN_SRC scheme

;; need delete getty service (tty3,tty4,tty5,tty6)

(dbus-service)
(syslog-service)
;; default
(service kmscon-service-type
 (kmscon-configuration
  (virtual-terminal "tty3")))
;; us
(service kmscon-service-type
 (kmscon-configuration
  (virtual-terminal "tty4")
   (keyboard-layout (keyboard-layout "us"))))
;; us with ctrl:nocaps options
(service kmscon-service-type
 (kmscon-configuration
  (virtual-terminal "tty5")
   (keyboard-layout
    (keyboard-layout "us" #:options '("ctrl:nocaps")))))
;; with all args
(service kmscon-service-type
 (kmscon-configuration
  (virtual-terminal "tty6")
   (keyboard-layout
    (keyboard-layout "us" "intl" #:model "macbook78" #:options
     '("ctrl:nocaps" "compose:menu")))))

#+END_SRC

then

guix system vm vm-configuration.scm

xxxxxxxxxx-vm.sh # need graphic 

in vm:

herd status # ensure services is running

# test
Ctrl + Alt + F3 # ensure it is us keyboard layout
Ctrl + Alt + F4 # ensure it is us keyboard layout
Ctrl + Alt + F5 # ensure Caps Locks is Ctrl
...







^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-05-04 11:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-24  5:37 [bug#47994] [PATCH] services: kmscon: Add xkb-layout and xkb-options fields luhui
2021-04-25  9:12 ` Maxime Devos
2021-04-25 10:04   ` luhui
2021-04-25 12:46     ` Maxime Devos
2021-04-26  2:07       ` luhui
2021-04-26 19:23         ` Maxime Devos
2021-05-04 11:32           ` luhui

unofficial mirror of guix-patches@gnu.org 

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhetil.org/guix-patches/1 guix-patches/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 guix-patches guix-patches/ https://yhetil.org/guix-patches \
		guix-patches@gnu.org
	public-inbox-index guix-patches

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://news.yhetil.org/yhetil.gnu.guix.patches


AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git