From d00e056cf71cfce98d2658d28e88aa0f063c6c49 Mon Sep 17 00:00:00 2001 From: Eric Hameleers Date: Wed, 20 Jul 2016 13:39:05 +0200 Subject: liveinit: optionally specify XkbOptions through the "xkb" boot parameter. Variable XKB can be set to "XkbLayout,XkbVariant,XkbOptions". For example "xkb=ch,fr,compose:sclk,grp:alt_shift_toggle" Note that the XkbOptions can be several comma-separated values. The XkbLayout and XkbVariant values must not contain commas. You can still set just the XkbVariant by adding something like "kbd=ch xkb=,fr" --- liveinit | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/liveinit b/liveinit index cbac798..8f4fa79 100755 --- a/liveinit +++ b/liveinit @@ -800,11 +800,16 @@ EOT fi if [ ! -z "$KEYMAP" -o ! -z "$XKB" ]; then # Set a keyboard mapping in X.Org, derived from the console map if needed: - # Variable XKB can be set to "XkbLayout,XkbVariant", like "xkb=ch,fr" + # Variable XKB can be set to "XkbLayout,XkbVariant,XkbOptions". + # For example "xkb=ch,fr,compose:sclk,grp:alt_shift_toggle" + # Note that the XkbOptions can be several comma-separated values. + # The XkbLayout and XkbVariant values must not contain commas. # You can set just the XkbVariant by adding something like "kbd=ch xkb=,fr" XKBLAYOUT=$(echo $XKB |cut -d, -f1) XKBVARIANT=$(echo $XKB |cut -d, -f2) - # Ensure that XKBLAYOUT gets a value; XKBVARIANT is allowed to be empty. + XKBOPTIONS=$(echo $XKB |cut -d, -f3-) + # Ensure that XKBLAYOUT gets a value; + # XKBVARIANT and XKBOPTIONS are allowed to be empty. if [ -z "$XKBLAYOUT" ]; then if [ -z "$KEYMAP" ]; then XKBLAYOUT="us" @@ -816,17 +821,27 @@ EOT XKBLAYOUT="us" fi echo "${MARKER}: Switching live X desktop to '$XKBLAYOUT' keyboard" - # Germans use the AltGr key, so Scroll Lock will be their Compose Key: - if [ "$XKBLAYOUT" = "de" ]; then - XKBOPTIONS="compose:sclk" - else - XKBOPTIONS="compose:ralt" - fi - # If the layout is not 'us' then add 'us' as a secondary nevertheless: + if [ "$XKBLAYOUT" != "us" ]; then + # If the layout is not 'us' then add 'us' as a secondary nevertheless: XKBLAYOUT="$XKBLAYOUT,us" XKBVARIANT="$XKBVARIANT," - XKBOPTIONS="grp:alt_shift_toggle,grp_led:scroll,$XKBOPTIONS" + fi + + if [ -z "$XKBOPTIONS" ]; then + # If the user did not specify any X keyboard options then we will + # determine a set of sane defaults: + if [ "$XKBLAYOUT" = "de" ]; then + # Germans use the AltGr key, so Scroll Lock will be their Compose Key: + XKBOPTIONS="compose:sclk" + else + # Rest of the world use the Right Alt (AltGr): + XKBOPTIONS="compose:ralt" + fi + if [ "$XKBLAYOUT" != "us" ]; then + # User should be able to switch between layouts: + XKBOPTIONS="grp:alt_shift_toggle,grp_led:scroll,$XKBOPTIONS" + fi fi mkdir -p /mnt/overlay/etc/X11/xorg.conf.d cat < /mnt/overlay/etc/X11/xorg.conf.d/30-keyboard.conf -- cgit v1.2.3