#!/bin/bash

exec >"$(basename $0)".log 2>&1

cat > scratch/myxkeyboard << EOF
Section "InputClass"
        Identifier "libinput keyboard catchall"
        MatchIsKeyboard "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"
        Option "XkbLayout" "fr"
        Option "Xkbvariant" "latin9"
        Option "xkbModel" "pc105"
        Option "xkboptions" "terminate:ctrl_alt_bksp"
EndSection
EOF
cat > scratch/myconf << EOF
[settings]
# Let's try spaces around the = sign
xkbdlayoutfile =     $(pwd)/scratch/myxkeyboard
EOF
. ${srcdir}/ref-dbus.sh
. ${srcdir}/ref-localed.sh --config scratch/myconf
gdbus introspect \
      --system \
      --dest org.freedesktop.locale1 \
      --object-path /org/freedesktop/locale1 \
      --only-properties | grep X11 | cmp ${srcdir}/scratch/xkeyboard-read-result1
RES=$?
rm scratch/myxkeyboard scratch/myconf
. ${srcdir}/unref-localed.sh
. ${srcdir}/unref-dbus.sh
exit $RES
