Created
March 16, 2022 12:27
-
-
Save cw2k/5b4d7a1dc3715ce368220b708874ac90 to your computer and use it in GitHub Desktop.
Localised keyboard layout Grub2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh -e | |
# /etc/grub.d/01_keyboard_layout.sh | |
# ^-Put this file here. | |
# and make it executable: | |
# chmod +x /etc/grub.d/01_keyboard_layout.sh | |
# | |
# update-grub | |
# ..and finally you've a localised keyboard layout in Grub2 | |
# (... inside the 'normal.mod' Grub; However the rescue shell *suprise* is not effected) | |
# | |
# Hmm I wonder why files like this aren't included by default in grub2? | |
grub_DirLayouts=/boot/grub/layouts | |
mkdir -p $grub_DirLayouts | |
# Cut off first part of $LANG, that is for example "de_DE.utf8" | |
GRUB_LANG=$( echo $LANG | cut -d_ -f1 ) | |
# Generate '/boot/grub/layouts/de.gkb | |
grub_localLayoutFile=$grub_DirLayouts/$GRUB_LANG.gkb | |
if test -f $grub_localLayoutFile | |
then echo "Using keyboard map $grub_localLayoutFile." >&2 | |
else echo "Generating keyboard map $grub_localLayoutFile." >&2 | |
ckbcomp $GRUB_LANG | grub-mklayout -o $grub_localLayoutFile | |
fi | |
cat <<-EOF | |
insmod keylayouts | |
keymap $GRUB_LANG | |
# Note: keymap does not affect 'console' so insert keyboards | |
terminal_input --append at_keyboard | |
terminal_input --append usb_keyboard | |
terminal_input --remove console | |
EOF | |
# Based on 'Re: Grub2 deutsche Tastatur' https://debianforum.de/forum/viewtopic.php?p=1176078#p1176078 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment