obosdi-pkg/config/xorg/keyboard
2022-11-10 22:27:23 +01:00

85 lines
2 KiB
Bash

#!/bin/bash
. ./lib
pacman -Q libxkbcommon 2> /dev/null
if [ "$?" = "1" ]; then
if(confirm "libxkbcommon is required to use localectl.\n\nInstall libxkbcommon?") then
instpkg "libxkbcommon" ""
else
exit 1
fi
fi
options=()
items=$(localectl list-x11-keymap-layouts)
for item in $items; do
options+=("$item" "")
done
layout=$(dialog --backtitle "$apptitle" --title "Select keyboard layout :" --cancel-button "Cancel" --menu "" 0 0 0 \
"${options[@]}" \
3>&1 1>&2 2>&3)
if [ ! "$?" = "0" ]; then
exit 1
fi
options=()
options+=("ignore" "")
options+=("pc104" "Default")
options+=("pc105" "")
items=$(localectl list-x11-keymap-models)
for item in $items; do
options+=("$item" "")
done
model=$(dialog --backtitle "$apptitle" --title "Select keyboard model :" --cancel-button "Cancel" --menu "" 0 0 0 \
"${options[@]}" \
3>&1 1>&2 2>&3)
if [ ! "$?" = "0" ]; then
exit 1
fi
if [ "$model" = "ignore" ]; then
model=""
fi
options=()
options+=("ignore" "Default")
items=$(localectl list-x11-keymap-variants $layout)
for item in $items; do
options+=("$item" "")
done
variant=$(dialog --backtitle "$apptitle" --title "Select keyboard variant :" --cancel-button "Cancel" --menu "" 0 0 0 \
"${options[@]}" \
3>&1 1>&2 2>&3)
if [ ! "$?" = "0" ]; then
exit 1
fi
if [ "$variant" = "ignore" ]; then
variant=""
fi
options=()
options+=("ignore" "Default")
options+=("terminate:ctrl_alt_bksp" "Default 2")
items=$(localectl list-x11-keymap-options)
for item in $items; do
options+=("$item" "")
done
option=$(dialog --backtitle "$apptitle" --title "Select keyboard option :" --cancel-button "Cancel" --menu "" 0 0 0 \
"${options[@]}" \
3>&1 1>&2 2>&3)
if [ ! "$?" = "0" ]; then
exit 1
fi
if [ "$option" = "ignore" ]; then
option=""
fi
if ( confirm "Run localectl set-x11-keymap $layout $model $variant $option ?") then
clear
echo "localectl set-x11-keymap $layout $model $variant $option"
localectl set-x11-keymap $layout $model $variant $option
pressanykey
fi
exit 0