Improve keyboard config generation

This commit is contained in:
Augusto Gunsch 2021-08-13 10:37:06 -03:00
parent 6f0c4d6360
commit cd42e11d81
No known key found for this signature in database
GPG Key ID: F7EEFE29825C72DC
2 changed files with 22 additions and 14 deletions

View File

@ -235,14 +235,13 @@ set_locale() {
echo "done"
echo -n "Setting keyboard layout..."
echo "KEYMAP=\"$KBD_LAYOUT\"" > /mnt/etc/vconsole.conf
XKBD="$(awk -F, '$1 ~ /^'$KBD_LAYOUT'$/ {print $0; exit 0}' keyboard-map.csv)"
XKBD_LAYOUT="$(echo $XKBD | awk -F, '{print $2}')"
XKBD_MODEL="$(echo $XKBD | awk -F, '{print $3}')"
XKBD_VARIANT="$(echo $XKBD | awk -F, '{print $4}')"
XKBD_OPTIONS="$(echo $XKBD | awk -F, '{print $5}')"
IFS=, read -r dummy XKBD_LAYOUT XKBD_MODEL XKBD_VARIANT XKBD_OPTIONS <<< "$(grep "^$KBD_LAYOUT," -m1 keyboard-map.csv)"
echo "KEYMAP=$KBD_LAYOUT" > /mnt/etc/vconsole.conf
echo "keymap=\"$XKBD_LAYOUT\"" > /mnt/etc/conf.d/keymaps
local XKBD_CONF="/mnt/etc/X11/xorg.conf.d/00-keyboard.conf"
mkdir -p $(dirname $XKBD_CONF)
echo "Section \"InputClass\"" > $XKBD_CONF
@ -250,9 +249,11 @@ set_locale() {
echo " MatchIsKeyboard \"on\"" >> $XKBD_CONF
echo " Option \"XkbLayout\" \"$XKBD_LAYOUT\"" >> $XKBD_CONF
echo " Option \"XkbModel\" \"$XKBD_MODEL\"" >> $XKBD_CONF
[ -n $XKBD_VARIANT ] && echo " Option \"XkbVariant\" \"$XKBD_VARIANT\"" >> $XKBD_CONF
[ -n $XKBD_OPTIONS ] && echo " Option \"XkbOptions\" \"$XKBD_OPTIONS\"" >> $XKBD_CONF
[ -n "$XKBD_VARIANT" ] && echo " Option \"XkbVariant\" \"$XKBD_VARIANT\"" >> $XKBD_CONF
[ -n "$XKBD_OPTIONS" ] && echo " Option \"XkbOptions\" \"$XKBD_OPTIONS\"" >> $XKBD_CONF
echo "EndSection" >> $XKBD_CONF
[ "$INIT_SYS" = "openrc-init" ] && quiet right_chroot /mnt rc-update add keymaps boot
echo "done"
}

View File

@ -183,6 +183,7 @@ print_phase() {
install_aur() {
qpushd "$AUR_BUILD_DIR"
[ -e "$1" ] && qpopd && return 0
quiet sudo -u nobody git clone -q "https://aur.archlinux.org/$1.git" "$1"
qpushd "$1"
@ -238,8 +239,14 @@ install_try_aur() {
fi
set +e
ultra_quiet pacman -Sq --needed --noconfirm $1
[ $? -ne 0 ] && set -e && echo "not found: will try from AUR" && install_aur $1
set -e
if [ $? -ne 0 ]; then
set -e
echo "not found: will try from AUR"
install_aur $1
else
set -e
echo "done"
fi
}
prompt() {
@ -457,7 +464,7 @@ install_dash() {
}
repos() {
echo "Detected distro $DISTRO Linux. Proceeding with enabling more repositories."
echo "Detected distro $DISTRO Linux. Proceeding with enabling more repositories"
if [ "$DISTRO" = "artix" ]; then
pacman_repo lib32
local ARCH_REPOS="$DEFAULT_INCLUDE-arch"
@ -509,7 +516,6 @@ install_dotfiles() {
[ "$INSTAL" = "PACKAGES" ] && return 0
print_phase "Dotfile installation"
install git
qpushd "$HOME_DIR"
install_dotfiles_for "$INSTALL_USER"
@ -527,6 +533,7 @@ install_dotfiles() {
install_src() {
# source code is stored in /root/builds
qpushd "$HOME"
[ -e "$1" ] && qpopd && return 0
local PKG_NAME="$(basename "$1")"
if [ -z "$2" ]; then
echo -ne "Installing ${LGREEN}$PKG_NAME${NC} from source..."
@ -571,8 +578,8 @@ install_packages() {
change_shells() {
echo -n "Configuring zsh..."
chsh -s /bin/zsh "root"
chsh -s /bin/zsh "$INSTALL_USER"
quiet chsh -s /bin/zsh "root"
quiet chsh -s /bin/zsh "$INSTALL_USER"
sed 's/^export PROMPT=.*/export PROMPT='"'"'%B%F{166}[%F{172}%n@%m %F{white}%~%F{166}]$%b%f '"'"'/' < "$HOME/.zshrc" > /tmp/zshrc
mv /tmp/zshrc "$HOME/.zshrc"
echo "done"