From mboxrd@z Thu Jan 1 00:00:00 1970 From: "pelzflorian (Florian Pelz)" Subject: bug#40493: installer: Provide a way to select multiple keyboard layouts Date: Tue, 7 Apr 2020 19:50:02 +0200 Message-ID: <20200407175002.uzjqzm7fdgxftrrn@pelzflorian.localdomain> References: <87369fmd8d.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="hveq455vskwi7jvf" Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:35179) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLsOK-0006GP-NN for bug-guix@gnu.org; Tue, 07 Apr 2020 13:52:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLsOI-0005mb-Iy for bug-guix@gnu.org; Tue, 07 Apr 2020 13:52:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:39280) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jLsOI-0005le-EM for bug-guix@gnu.org; Tue, 07 Apr 2020 13:52:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jLsOI-0004Tf-A3 for bug-guix@gnu.org; Tue, 07 Apr 2020 13:52:02 -0400 Sender: "Debbugs-submit" Resent-Message-ID: Received: from eggs.gnu.org ([2001:470:142:3::10]:34981) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLsMT-0005UD-3L for bug-guix@gnu.org; Tue, 07 Apr 2020 13:50:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLsMQ-0004h5-W6 for bug-guix@gnu.org; Tue, 07 Apr 2020 13:50:08 -0400 Received: from pelzflorian.de ([5.45.111.108]:41564 helo=mail.pelzflorian.de) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLsMQ-0004gC-BL for bug-guix@gnu.org; Tue, 07 Apr 2020 13:50:06 -0400 Content-Disposition: inline In-Reply-To: <87369fmd8d.fsf@gmail.com> List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane-mx.org@gnu.org Sender: "bug-Guix" To: Mathieu Othacehe Cc: 40493@debbugs.gnu.org --hveq455vskwi7jvf Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Apr 07, 2020 at 07:12:34PM +0200, Mathieu Othacehe wrote: > Now it would be nice to support multiple keyboard layout selection from > the installer, so that a configuration like to one above is generated. >=20 > Thanks, >=20 > Mathieu Ludo responded to the other bug: On Tue, Apr 07, 2020 at 11:49:09AM +0200, Ludovic Court=C3=A8s wrote: > Ideally we=E2=80=99d also offer a way to choose multiple layouts in the > installer, so that one can end up with: > > (keyboard-layout "ar,us" #:options '("grp:alt_shift_toggle")) > I believe the user should not have to manually select the other layout (if the user wants they can select via F1 key). Instead there should be a sane default (typically U.S. layout). But since I am used to Latin script, I may not have good judgment. IMHO two things should be done: * Within the installer, a toggleable second keyboard layout should be available by default. Mathieu enabled changing the layout via the F1 help menu. This is good and more flexible and discoverable, but a key combination is more convenient and people appear to be used to Alt+Shift toggling. * In the config.scm created by the installer, the default keyboard-layout should include the second layout. Both the config.scm default and the installer layout should be the same, I think. I attach a proposed solution for the first thing, though it does not yet update the toggle option correctly. If you think the approach is OK, then I will add more default alternative layouts to the maybe-add-second-layout procedure. > Although that=E2=80=99s mostly useful for the console as GDM and GNOME = should be > able to do the right thing. >=20 > Anyway, we can discuss it in a separate issue. >=20 > Ludo=E2=80=99. The GNOME session after login will ask the user what keyboard layout they want, but the (I believe changeable) default for GDM comes from config.scm. Regards, Florian --hveq455vskwi7jvf Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: attachment; filename="0001-installer-Allow-Alt-Shift-toggle-from-non-Latin-keyb.patch" Content-Transfer-Encoding: quoted-printable >From 0d3a1ecc214fe55d77f45f4b2e690a93978da9ec Mon Sep 17 00:00:00 2001 From: Florian Pelz Date: Tue, 7 Apr 2020 19:06:31 +0200 Subject: [PATCH] installer: Allow Alt+Shift toggle from non-Latin keyboar= d layouts. See . * gnu/installer/newt/keymap.scm (run-keymap-page): Maybe add second layou= t. * gnu/installer/keymap.scm (kmscon-update-keymap): Pass on XKB options. * gnu/installer/records.scm (): Adjust code comments. * gnu/installer.scm (apply-keymap): Pass on XKB options. (installer-steps): Adjust code comments. * gnu/packages/patches/kmscon-runtime-keymap-switch.patch: Apply XKB opti= ons. --- gnu/installer.scm | 14 +++++----- gnu/installer/keymap.scm | 8 ++++-- gnu/installer/newt/keymap.scm | 19 ++++++++++--- gnu/installer/record.scm | 3 ++- .../kmscon-runtime-keymap-switch.patch | 27 ++++++------------- 5 files changed, 40 insertions(+), 31 deletions(-) diff --git a/gnu/installer.scm b/gnu/installer.scm index 75c5a01570..72b7d195fd 100644 --- a/gnu/installer.scm +++ b/gnu/installer.scm @@ -2,6 +2,7 @@ ;;; Copyright =A9 2018, 2020 Mathieu Othacehe ;;; Copyright =A9 2019, 2020 Ludovic Court=E8s ;;; Copyright =A9 2019, 2020 Tobias Geerinckx-Rice +;;; Copyright =A9 2020 Florian Pelz ;;; ;;; This file is part of GNU Guix. ;;; @@ -170,9 +171,9 @@ been performed at build time." (define apply-keymap ;; Apply the specified keymap. Use the default keyboard model. #~(match-lambda - ((layout variant) + ((layout variant options) (kmscon-update-keymap (default-keyboard-model) - layout variant)))) + layout variant options)))) =20 (define* (compute-keymap-step context) "Return a gexp that runs the keymap-page of INSTALLER and install the @@ -235,12 +236,13 @@ selected keymap." =20 ;; The installer runs in a kmscon virtual terminal where loadke= ys ;; won't work. kmscon uses libxkbcommon as a backend for keyboa= rd - ;; input. It is possible to update kmscon current keymap by sen= ding it - ;; a keyboard model, layout and variant, in a somehow similar w= ay as - ;; what is done with setxkbmap utility. + ;; input. It is possible to update kmscon current keymap by sen= ding + ;; it a keyboard model, layout, variant and options, in a someh= ow + ;; similar way as what is done with setxkbmap utility. ;; ;; So ask for a keyboard model, layout and variant to update th= e - ;; current kmscon keymap. + ;; current kmscon keymap. For non-Latin layouts, we add an + ;; appropriate second layout and toggle via Alt+Shift. (installer-step (id 'keymap) (description (G_ "Keyboard mapping selection")) diff --git a/gnu/installer/keymap.scm b/gnu/installer/keymap.scm index df9fc5e441..d520b782fd 100644 --- a/gnu/installer/keymap.scm +++ b/gnu/installer/keymap.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright =A9 2018 Mathieu Othacehe +;;; Copyright =A9 2020 Florian Pelz ;;; ;;; This file is part of GNU Guix. ;;; @@ -154,8 +155,8 @@ Configuration Database, describing possible XKB confi= gurations." ((models layouts) (values models layouts))))) =20 -(define (kmscon-update-keymap model layout variant) - "Update kmscon keymap with the provided MODEL, LAYOUT and VARIANT." +(define (kmscon-update-keymap model layout variant options) + "Update kmscon keymap with the provided MODEL, LAYOUT, VARIANT and OPT= IONS." (and=3D> (getenv "KEYMAP_UPDATE") (lambda (keymap-file) @@ -175,4 +176,7 @@ Configuration Database, describing possible XKB confi= gurations." (put-u8 port 0) =20 (format port variant) + (put-u8 port 0) + + (format port options) (put-u8 port 0)))))) diff --git a/gnu/installer/newt/keymap.scm b/gnu/installer/newt/keymap.sc= m index 0147a0b9d5..ba02085a44 100644 --- a/gnu/installer/newt/keymap.scm +++ b/gnu/installer/newt/keymap.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright =A9 2018, 2020 Mathieu Othacehe ;;; Copyright =A9 2019 Ludovic Court=E8s +;;; Copyright =A9 2020 Florian Pelz ;;; ;;; This file is part of GNU Guix. ;;; @@ -114,8 +115,10 @@ You can switch to different layout at any time from = the help menu."))) =20 (define* (run-keymap-page layouts #:key (context #f)) "Run a page asking the user to select a keyboard layout and variant. L= AYOUTS -is a list of supported X11-KEYMAP-LAYOUT. Return a list of two elements,= the -names of the selected keyboard layout and variant." +is a list of supported X11-KEYMAP-LAYOUT. For non-Latin keyboard layout= s, a +second layout and toggle options will be added automatically. Return a = list +of three elements, the names of the selected keyboard layout, variant an= d +optionsxs." (define keymap-steps (list (installer-step @@ -144,6 +147,15 @@ names of the selected keyboard layout and variant." (gettext (x11-keymap-variant-description variant) "xkeyboard-config")))))))))) =20 + (define (maybe-add-second-layout first-layout) + "Return for a chosen keyboard layout either the same layout or possi= bly +the layout plus a suitable second layout, and also variant and options." + (match first-layout + (("ar" "azerty") (list "ar,fr" "azerty," "grp:alt_shift_toggle")) + (("ar" variant) (list "ar,us" variant "grp:alt_shift_toggle")) + (("ja" variant) (list "ja,us" variant "grp:alt_shift_toggle")) + ((layout variant) (list layout variant "")))) + (define (format-result result) (let ((layout (x11-keymap-layout-name (result-step result 'layout))) @@ -151,7 +163,8 @@ names of the selected keyboard layout and variant." (lambda (variant) (gettext (x11-keymap-variant-name variant) "xkeyboard-config"))))) - (list layout (or variant "")))) + (maybe-add-second-layout + (list layout (or variant ""))))) (format-result (run-installer-steps #:steps keymap-steps))) =20 diff --git a/gnu/installer/record.scm b/gnu/installer/record.scm index 78acf50c63..13acd33fc6 100644 --- a/gnu/installer/record.scm +++ b/gnu/installer/record.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright =A9 2018, 2020 Mathieu Othacehe +;;; Copyright =A9 2020 Florian Pelz ;;; ;;; This file is part of GNU Guix. ;;; @@ -63,7 +64,7 @@ (exit-error installer-exit-error) ;; procedure void -> void (final-page installer-final-page) - ;; procedure (layouts context) -> (list layout variant) + ;; procedure (layouts context) -> (list layout variant options) (keymap-page installer-keymap-page) ;; procedure: (#:key supported-locales iso639-languages iso3166-territ= ories) ;; -> glibc-locale diff --git a/gnu/packages/patches/kmscon-runtime-keymap-switch.patch b/gn= u/packages/patches/kmscon-runtime-keymap-switch.patch index 656c76fa40..deb5688daf 100644 --- a/gnu/packages/patches/kmscon-runtime-keymap-switch.patch +++ b/gnu/packages/patches/kmscon-runtime-keymap-switch.patch @@ -1,14 +1,5 @@ -From 360d44d67e7be46108bec982ff2e79b89f04a9a3 Mon Sep 17 00:00:00 2001 -From: Mathieu Othacehe -Date: Thu, 15 Nov 2018 14:34:40 +0900 -Subject: [PATCH] add runtime keymap switch support. - ---- - src/pty.c | 23 ++++++++++- - src/uterm_input.c | 2 + - src/uterm_input_internal.h | 5 +++ - src/uterm_input_uxkb.c | 83 ++++++++++++++++++++++++++++++++++++++ - 4 files changed, 111 insertions(+), 2 deletions(-) +By Mathieu Othacehe . +Modified by Florian Pelz . =20 diff --git a/src/pty.c b/src/pty.c index 1443f4a..f64cb5b 100644 @@ -124,7 +115,7 @@ index 04e6cc9..ec44459 100644 uint16_t key_state, uint16_t code); diff --git a/src/uterm_input_uxkb.c b/src/uterm_input_uxkb.c -index 925c755..4760972 100644 +index 925c755..5d5c22e 100644 --- a/src/uterm_input_uxkb.c +++ b/src/uterm_input_uxkb.c @@ -31,6 +31,9 @@ @@ -137,7 +128,7 @@ index 925c755..4760972 100644 #include #include "shl_hook.h" #include "shl_llog.h" -@@ -178,6 +181,86 @@ static void timer_event(struct ev_timer *timer, uin= t64_t num, void *data) +@@ -178,6 +181,87 @@ static void timer_event(struct ev_timer *timer, uin= t64_t num, void *data) shl_hook_call(dev->input->hook, dev->input, &dev->repeat_event); } =20 @@ -145,11 +136,11 @@ index 925c755..4760972 100644 +{ + struct uterm_input_dev *dev =3D data; + char in; -+ char keymap[3][255]; ++ char keymap[4][255]; + int pos =3D 0; + int curr_keymap =3D 0; + int ret; -+ char *model, *layout, *variant; ++ char *model, *layout, *variant, *options; + + if (!(mask & EV_READABLE)) + return; @@ -159,6 +150,7 @@ index 925c755..4760972 100644 + model =3D keymap[0]; + layout =3D keymap[1]; + variant =3D keymap[2]; ++ options =3D keymap[3]; + + do { + ret =3D read(dev->rupdate_fd, &in, sizeof(in)); @@ -175,7 +167,7 @@ index 925c755..4760972 100644 + + llog_info(dev->input, "HANDLER CALLED %s|%s|%s\n", + model, layout, variant); -+ uxkb_desc_init(dev->input, model, layout, variant, NULL, NULL); ++ uxkb_desc_init(dev->input, model, layout, variant, options, NULL); + + dev->state =3D xkb_state_new(dev->input->keymap); + if (!dev->state) { @@ -224,6 +216,3 @@ index 925c755..4760972 100644 int uxkb_dev_init(struct uterm_input_dev *dev) { int ret; ---=20 -2.17.1 - --=20 2.26.0 --hveq455vskwi7jvf--