From cea6043290fb411ad7c693007e4f62fc8687a02d Mon Sep 17 00:00:00 2001 From: Eric Hameleers Date: Tue, 5 Jan 2016 09:36:14 +0100 Subject: Added support for separate configuration of X keyboard layout/variant. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit New parameter for the boot commandline: xkb=[language],variant Examples: # Only specify a Xkbvariant, and inherit the console keyboard layout in X: kbd=nl xkb=,sundeadkeys # Define a 'french swiss' layout in X, independent of the console: xkb=ch,fr Two new keyboard/language choices have been added which use this functionality: - german swiss - french swiss (requested by Niki Kovacs). New: if a non-US keyboard layout is selected, the US layout will be added as a secondary layout. Toggling between the two layouts is possible using the Shift-LeftAlt key combo. Also new: the RightAlt key is now defined as the Compose Key in X. Meaning, the combo <"> will generate a 'ë character'. --- liveinit | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'liveinit') diff --git a/liveinit b/liveinit index 74e8cde..2193b33 100755 --- a/liveinit +++ b/liveinit @@ -124,6 +124,9 @@ for ARG in $(cat /proc/cmdline); do waitforroot=*|rootdelay=*) WAIT=$(echo $ARG | cut -f2 -d=) ;; + xkb=*) + XKB=$(echo $ARG | cut -f2 -d=) + ;; esac done @@ -376,7 +379,7 @@ if [ "$RESCUE" = "" ]; then if [ ! -z "$KEYMAP" ]; then # Configure custom keyboard mapping in console and X: - echo "${INITRD}: Switching live desktop to '$KEYMAP' keyboard" + echo "${INITRD}: Switching live console to '$KEYMAP' keyboard" cat < /mnt/overlay/etc/rc.d/rc.keymap #!/bin/sh # Load the keyboard map. More maps are in /usr/share/kbd/keymaps. @@ -385,13 +388,37 @@ if [ -x /usr/bin/loadkeys ]; then fi EOT chmod 755 /mnt/overlay/etc/rc.d/rc.keymap - # Set a usable keyboard mapping in X.Org, derived from the console map: + 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" + # 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) + XKBOPTIONS="compose:ralt" + # Ensure that XKBLAYOUT gets a value; XKBVARIANT is allowed to be empty. + if [ -z "$XKBLAYOUT" ]; then + if [ -z "$KEYMAP" ]; then + XKBLAYOUT="us" + else + XKBLAYOUT="$(echo $KEYMAP |cut -c1-2)" + fi + fi + echo "${INITRD}: Switching live X desktop to '$XKBLAYOUT' keyboard" + # If the layout is not 'us' then add 'us' as a secondary nevertheless: + if [ "$XKBLAYOUT" != "us" ]; then + XKBLAYOUT="$XKBLAYOUT,us" + XKBVARIANT="$XKBVARIANT," + XKBOPTIONS="grp:alt_shift_toggle,$XKBOPTIONS" + fi mkdir -p /mnt/overlay/etc/X11/xorg.conf.d cat < /mnt/overlay/etc/X11/xorg.conf.d/30-keyboard.conf Section "InputClass" Identifier "keyboard-all" Driver "evdev" - Option "XkbLayout" "$(echo $KEYMAP |cut -c1-2)" + Option "XkbLayout" "$XKBLAYOUT" + Option "XkbVariant" "$XKBVARIANT" + Option "XkbOptions" "$XKBOPTIONS" MatchIsKeyboard "on" EndSection EOT -- cgit v1.2.3