xorg: configure keyboard using /etc/X11/xorg.conf.d/ directory; requires Xorg >= 1.10

This commit is contained in:
Silvan Calarco 2011-08-14 19:36:45 +02:00
parent b900184fc5
commit dafeaa790b

View File

@ -106,39 +106,42 @@ _EOF
}
}
function xorg_hal_configure_keyboard() {
# Keyboard configuration (Xorg >= 1.4 uses HAL)
[ ! -e /etc/hal/fdi/policy/10-keymap.fdi -o \
/etc/sysconfing/keyboard -nt /etc/hal/fdi/policy/10-keymap.fdi ] && {
function xorg_d_configure_keyboard() {
# Keyboard configuration (Xorg >= 1.8 uses /etc/X11/xorg.conf.d)
[ ! -e /etc/X11/xorg.conf.d/10-keyboard.conf -o \
/etc/sysconfing/keyboard -nt /etc/X11/xorg.conf.d/10-keyboard.conf ] && {
if [ ! "$XKB_MODEL" -o ! "$XKB_LAYOUT" ]; then
case "${LANG:0:2}" in
it)
XKB_MODEL="pc105"
# XKB_MODEL="pc105"
XKB_LAYOUT="it" ;;
de)
XKB_MODEL="pc105"
# XKB_MODEL="pc105"
XKB_LAYOUT="de" ;;
es)
XKB_MODEL="pc105"
# XKB_MODEL="pc105"
XKB_LAYOUT="es" ;;
fr)
XKB_MODEL="pc105"
# XKB_MODEL="pc105"
XKB_LAYOUT="fr" ;;
*)
XKB_MODEL="pc104"
# XKB_MODEL="pc104"
XKB_LAYOUT="us" ;;
esac
fi
cat > /etc/hal/fdi/policy/10-keymap.fdi << __EOF
<?xml version="1.0" encoding="ISO-8859-1"?> <!-- -*- SGML -*- -->
<match key="info.capabilities" contains="input.keys">
<merge key="input.xkb.layout" type="string">$XKB_LAYOUT</merge>
<merge key="input.xkb.model" type="string">$XKB_MODEL</merge>
<merge key="input.xkb.rules" type="string">base</merge>
</match>
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
}
}
@ -200,7 +203,7 @@ if [ ! -e $XORGCONF ]; then
HOME=/tmp Xorg :5 -configure 2>>$logfile || {
logmsg "$me" "warning: xorg autoprobed configuration failed; enabling experimental xorg autoconfig"
xorg_configure_loginmanager
xorg_hal_configure_keyboard
xorg_d_configure_keyboard
exit 1
}
@ -478,7 +481,7 @@ sed -i "/[[:space:]]*InputDevice[[:space:]]*.*PS2Mouse.*/d; \
sed -i "/\W*Option \"Device\".*/d" $XORGCONF
# Configure keyboard
xorg_hal_configure_keyboard
xorg_d_configure_keyboard
# disable keyboard configuration for Xorg >= 1.4
sed -i "s|^\([[:space:]]*InputDevice\W*\"Keyboard0\".*\)|#\1|" $XORGCONF