This is /usr/etc/X11/xdm/keytable, rewritten with the logic "straightened up" in a way that IMHO makes it much more readable and with the additional "localectl set-x11-keymap". IDK if this rewrite is worth the hassle of testing and risk of regression... just including it in case it's of any use. #! /bin/bash if [ $UID -ne 0 ]; then echo "You need to be root to run this program" exit 0 fi vconsole_conf_file=/etc/vconsole.conf previous_x11conf_file=/etc/X11/xorg.conf.d/90-keytable.conf systemd_x11conf_file=/etc/X11/xorg.conf.d/00-keyboard.conf keyboard_map_systemd=/usr/share/systemd/kbd-model-map # Systamd's localectl replicates the keyboard configuration accross different # files ($vconsole_conf_file and, depending on version, $systemd_x11conf_file # or $previous_x11conf_file). # # To make sure it is consinstent everywhere, this scripts calls localectl with # the configuration from $vconsole_conf_file, which will cause the various # configuration files to be updated as neeeded. # # Moreover, this script also removes $previous_x11conf_file if it seems safe # to do so. if [ ! -f $vconsole_conf_file ]; then echo "$vconsole_conf_file not available" echo "Keyboard layout could not be set" exit 1 fi echo "$vconsole_conf_file available" . $vconsole_conf_file # sample variables loaded from $vconsole_conf_file: # KEYMAP=us-altgr-intl # FONT=eurlatgr.psfu # FONT_MAP= # FONT_UNIMAP= # XKBLAYOUT=us # XKBMODEL=pc104 # XKBVARIANT=altgr-intl # XKBOPTIONS=compose:menu,terminate:ctrl_alt_bksp if [ -z $KEYMAP ]; then echo "KEYMAP not set" echo "Keyboard layout could not be set" exit 1 fi echo "KEYMAP: $KEYMAP" if [ ! -f $systemd_x11conf_file ]; then localectl set-x11-keymap us fi opts=$(grep -P "^$KEYMAP\t" "$keyboard_map_systemd" | sed -re "s/[^\t]*//" -e "s/[\t]+/ /g" ) if [ -z "$opts" ]; then echo "W: Cannot find mapping for $KEYMAP in $keyboard_map_systemd" echo "W: This will result in an 'us' X keyboard layout as default" else echo "I: Using systemd $keyboard_map_systemd mapping" fi localectl set-keymap $KEYMAP $KEYMAP_TOGGLE if [ ! -z $XKBLAYOUT ]; then localectl set-x11-keymap $XKBLAYOUT $XKBMODEL $XKBVARIANT $XKBOPTIONS fi if [ ! -f $systemd_x11conf_file ]; then echo "$systemd_x11conf_file has not been created!" echo "Keyboard layout could not be set" ##### does this make sense here? exit 1 fi if [ -f $previous_x11conf_file ]; then if [ $systemd_x11conf_file -nt $previous_x11conf_file ]; then rm -f $previous_x11conf_file fi fi