xorg: use localectl to configure X11 keyboard layout; ensure it is always configuring it

This commit is contained in:
Silvan Calarco 2014-06-29 19:56:04 +02:00
parent c87575239b
commit 8598291d84

View File

@ -71,9 +71,7 @@ fi
function xorg_d_configure_input() { function xorg_d_configure_input() {
# Keyboard configuration (Xorg >= 1.8 uses /etc/X11/xorg.conf.d) # Keyboard configuration (Xorg >= 1.8 uses /etc/X11/xorg.conf.d)
[ ! -e /etc/X11/xorg.conf.d/10-keyboard.conf -o \ [ ! -e /etc/X11/xorg.conf.d/00-keyboard.conf ] && {
/etc/sysconfig/keyboard -nt /etc/X11/xorg.conf.d/10-keyboard.conf ] && {
if [ ! "$XKB_MODEL" -o ! "$XKB_LAYOUT" ]; then if [ ! "$XKB_MODEL" -o ! "$XKB_LAYOUT" ]; then
case "${LANG:0:2}" in case "${LANG:0:2}" in
it) it)
@ -93,33 +91,19 @@ function xorg_d_configure_input() {
XKB_LAYOUT="us" ;; XKB_LAYOUT="us" ;;
esac esac
fi 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 # configure keyboard options for Apple computers
if [ "${SYSTEM_MANUFACTURER:0:5}" = "Apple" ]; then if [ "${SYSTEM_MANUFACTURER:0:5}" = "Apple" ]; then
cat > /etc/X11/xorg.conf.d/15-keyboard-apple.conf << __EOF XKB_OPTIONS="$XKB_OPTIONS,lv3:rwin_switch"
Section "InputClass" fi
Identifier "Keyboard mac" localectl set-x11-keymap $XKB_LAYOUT $XKB_MODEL $XKB_VARIANT $XKB_OPTIONS && {
Driver "evdev" if [ -e /etc/X11/xorg.conf.d/10-keyboard.conf ]; then
Option "XkbOptions" ",lv3:rwin_switch" # Mac only rm -f /etc/X11/xorg.conf.d/10-keyboard.conf
MatchIsKeyboard "on" fi
EndSection if [ -e /etc/X11/xorg.conf.d/15-keyboard-apple.conf ]; then
__EOF
elif [ -e /etc/X11/xorg.conf.d/15-keyboard-apple.conf ]; then
rm -f /etc/X11/xorg.conf.d/15-keyboard-apple.conf rm -f /etc/X11/xorg.conf.d/15-keyboard-apple.conf
fi fi
}
}
[ ! -e /etc/X11/xorg.conf.d/20-synaptics.conf ] && { [ ! -e /etc/X11/xorg.conf.d/20-synaptics.conf ] && {
cat > /etc/X11/xorg.conf.d/20-touchpad.conf << __EOF cat > /etc/X11/xorg.conf.d/20-touchpad.conf << __EOF
@ -462,6 +446,9 @@ if [ -e /sys/class/drm/card0/device/power_profile ]; then
echo mid > /sys/class/drm/card0/device/power_profile echo mid > /sys/class/drm/card0/device/power_profile
fi fi
# Configure keyboard
xorg_d_configure_input
[ -e $XORGCONF -a "$VIDEODRIVER" ] || exit 0 [ -e $XORGCONF -a "$VIDEODRIVER" ] || exit 0
# add missing brackets to Xorg.conf device entries # add missing brackets to Xorg.conf device entries
@ -504,8 +491,6 @@ sed -i "/\W*Option \"Device\".*/d" $XORGCONF
# remove obsoleted XAANoOffscreenPixmaps # remove obsoleted XAANoOffscreenPixmaps
sed -i '/^[[:space:]]*Option[[:space:]]*"XAANoOffscreenPixmaps" "true"/d' $XORGCONF sed -i '/^[[:space:]]*Option[[:space:]]*"XAANoOffscreenPixmaps" "true"/d' $XORGCONF
# Configure keyboard
xorg_d_configure_input
# disable keyboard configuration for Xorg >= 1.4 # disable keyboard configuration for Xorg >= 1.4
sed -i "s|^\([[:space:]]*InputDevice\W*\"Keyboard0\".*\)|#\1|" $XORGCONF sed -i "s|^\([[:space:]]*InputDevice\W*\"Keyboard0\".*\)|#\1|" $XORGCONF