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