#!/bin/sh
#
# Trivial egregious hack to load the console keyboard layout into XKB.
#

. /etc/sysconfig/keyboard > /dev/null 2> /dev/null || exit 0

if [ -z "$XkbLayout" ]; then
    [ -x /usr/sbin/keyboarddrake ] || exit 0
    /usr/sbin/keyboarddrake --migrate
    . /etc/sysconfig/keyboard
fi

[ -n "$XkbLayout" ] || exit 0

if [ -n "$UDEV_LOG" ]; then
    # if $UDEV_LOG is set, I hope we're being called by udev
    [ -z "$XkbModel" ]    || echo "xkb.model=$XkbModel"
    [ -z "$XkbLayout" ]   || echo "xkb.layout=$XkbLayout"
    [ -z "$XkbVariant" ]  || echo "xkb.variant=$XkbVariant"
    [ -z "$XkbOptions" ]  || echo "xkb.options=$XkbOptions"
else
    # we're being called stand-alone
    # this will not work if we're not root
    [ -x /sbin/udevadm ] && /sbin/udevadm trigger --subsystem-match=input
fi
