From 8598291d84e83d42c672085603556a6f994f1dd2 Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Sun, 29 Jun 2014 19:56:04 +0200 Subject: [PATCH] xorg: use localectl to configure X11 keyboard layout; ensure it is always configuring it --- postplug.d/30xorg | 47 ++++++++++++++++------------------------------- 1 file changed, 16 insertions(+), 31 deletions(-) diff --git a/postplug.d/30xorg b/postplug.d/30xorg index bd15379..6862bbd 100644 --- a/postplug.d/30xorg +++ b/postplug.d/30xorg @@ -71,9 +71,7 @@ fi function xorg_d_configure_input() { # Keyboard configuration (Xorg >= 1.8 uses /etc/X11/xorg.conf.d) - [ ! -e /etc/X11/xorg.conf.d/10-keyboard.conf -o \ - /etc/sysconfig/keyboard -nt /etc/X11/xorg.conf.d/10-keyboard.conf ] && { - + [ ! -e /etc/X11/xorg.conf.d/00-keyboard.conf ] && { if [ ! "$XKB_MODEL" -o ! "$XKB_LAYOUT" ]; then case "${LANG:0:2}" in it) @@ -93,34 +91,20 @@ function xorg_d_configure_input() { XKB_LAYOUT="us" ;; esac fi - - cat > /etc/X11/xorg.conf.d/10-keyboard.conf << __EOF -Section "InputClass" - Identifier "Keyboard Defaults" - MatchIsKeyboard "on" - Driver "evdev" - Option "XkbLayout" "$XKB_LAYOUT" -__EOF - [ "$XKB_MODEL" ] && echo " Option \"XkbModel\" \"$XKB_MODEL\"" >>/etc/X11/xorg.conf.d/10-keyboard.conf - [ "$XKB_VARIANT" ] && echo " Option \"XkbVariant\" \"$XKB_VARIANT\"" >>/etc/X11/xorg.conf.d/10-keyboard.conf - [ "$XKB_OPTIONS" ] && echo " Option \"XkbOptions\" \"$XKB_OPTIONS\"" >>/etc/X11/xorg.conf.d/10-keyboard.conf - echo "EndSection" >>/etc/X11/xorg.conf.d/10-keyboard.conf + # configure keyboard options for Apple computers + if [ "${SYSTEM_MANUFACTURER:0:5}" = "Apple" ]; then + XKB_OPTIONS="$XKB_OPTIONS,lv3:rwin_switch" + fi + localectl set-x11-keymap $XKB_LAYOUT $XKB_MODEL $XKB_VARIANT $XKB_OPTIONS && { + if [ -e /etc/X11/xorg.conf.d/10-keyboard.conf ]; then + rm -f /etc/X11/xorg.conf.d/10-keyboard.conf + fi + if [ -e /etc/X11/xorg.conf.d/15-keyboard-apple.conf ]; then + rm -f /etc/X11/xorg.conf.d/15-keyboard-apple.conf + fi + } } - # configure keyboard options for Apple computers - if [ "${SYSTEM_MANUFACTURER:0:5}" = "Apple" ]; then - cat > /etc/X11/xorg.conf.d/15-keyboard-apple.conf << __EOF -Section "InputClass" - Identifier "Keyboard mac" - Driver "evdev" - Option "XkbOptions" ",lv3:rwin_switch" # Mac only - MatchIsKeyboard "on" -EndSection -__EOF - elif [ -e /etc/X11/xorg.conf.d/15-keyboard-apple.conf ]; then - rm -f /etc/X11/xorg.conf.d/15-keyboard-apple.conf - fi - [ ! -e /etc/X11/xorg.conf.d/20-synaptics.conf ] && { cat > /etc/X11/xorg.conf.d/20-touchpad.conf << __EOF Section "InputClass" @@ -462,6 +446,9 @@ if [ -e /sys/class/drm/card0/device/power_profile ]; then echo mid > /sys/class/drm/card0/device/power_profile fi +# Configure keyboard +xorg_d_configure_input + [ -e $XORGCONF -a "$VIDEODRIVER" ] || exit 0 # add missing brackets to Xorg.conf device entries @@ -504,8 +491,6 @@ sed -i "/\W*Option \"Device\".*/d" $XORGCONF # remove obsoleted XAANoOffscreenPixmaps sed -i '/^[[:space:]]*Option[[:space:]]*"XAANoOffscreenPixmaps" "true"/d' $XORGCONF -# Configure keyboard -xorg_d_configure_input # disable keyboard configuration for Xorg >= 1.4 sed -i "s|^\([[:space:]]*InputDevice\W*\"Keyboard0\".*\)|#\1|" $XORGCONF