systemrescue-zfs/airootfs/usr/bin/setkmap

24 lines
773 B
Plaintext
Raw Normal View History

2019-02-02 12:22:52 +01:00
#!/bin/bash
# Pass the name of the keyboard layout to load it directly (eg: "setkmap us")
# Pass no argument to display a menu a choose the keyboard layout from the list
keymaps=$(localectl list-keymaps)
if test -n "${1}" && localectl list-keymaps | grep -q "${1}"
then
keymap="${1}"
else
exec 3>&1
keymap=$(/sbin/dialog --title "Keyboard layout" --menu "Choose a keyboard layout" 25 50 20 $(for item in ${keymaps[@]}; do echo ${item} "-" ; done) 2>&1 1>&3) || exit 1
exec 3>&-
fi
localectl set-keymap ${keymap}
if [[ $DISPLAY ]] && [[ -r /etc/X11/xorg.conf.d/00-keyboard.conf ]]; then
# X11 is already running
x11keymap=$(awk '/^\s*Option "XkbLayout"/ { print $3 }' /etc/X11/xorg.conf.d/00-keyboard.conf)
setxkbmap -layout ${x11keymap}
fi