archboot/usr/bin/archboot-km.sh

78 lines
2.9 KiB
Bash
Raw Permalink Normal View History

#!/usr/bin/env bash
# SPDX-License-Identifier: GPL-2.0-only
2008-10-20 22:39:25 +02:00
# written by Tobias Powalowski <tpowa@archlinux.org>
2023-01-08 08:57:51 +01:00
_ANSWER="/tmp/.km"
2023-06-24 22:02:53 +02:00
_TITLE="Archboot | Arch Linux Setup | Console Configuration"
2023-01-09 08:57:23 +01:00
_LIST_MAPS="localectl list-keymaps --no-pager"
# _dialog()
# an el-cheapo dialog wrapper
#
# parameters: see dialog(1)
# returns: whatever dialog did
_dialog() {
dialog --backtitle "${_TITLE}" --aspect 15 "$@"
return $?
}
_do_vconsole() {
2023-01-19 08:04:48 +01:00
_dialog --infobox "Setting console font ${_FONT} and keymap ${_KEYMAP}..." 3 80
2023-01-08 08:57:51 +01:00
echo KEYMAP="${_KEYMAP}" > /etc/vconsole.conf
echo FONT="${_FONT}" >> /etc/vconsole.conf
systemctl restart systemd-vconsole-setup
2022-11-28 09:09:23 +01:00
sleep 2
2023-03-09 13:08:42 +01:00
_dialog --infobox "Console Font and Keymap setting completed successfully.\nContinuing in 5 seconds..." 4 60
sleep 5
return 0
2022-11-27 19:23:06 +01:00
}
2023-01-09 08:57:23 +01:00
_set_vconsole() {
2023-01-29 18:15:21 +01:00
if grep -q '^FONT=.*32' /etc/vconsole.conf; then
2023-01-26 19:59:31 +01:00
_FONTS="ter-v32n Worldwide latarcyrheb-sun32 Worldwide"
else
2023-01-26 19:59:31 +01:00
_FONTS="ter-v16n Worldwide latarcyrheb-sun16 Worldwide eurlatgr Europe"
2011-02-04 18:15:22 +01:00
fi
2023-03-07 17:37:25 +01:00
#shellcheck disable=SC2086
2023-03-08 22:42:24 +01:00
_dialog --menu " Select Console Font:\n\n Font Name Region" 12 40 14 ${_FONTS} 2>${_ANSWER} || return 1
2023-03-07 17:37:25 +01:00
#shellcheck disable=SC2086
_FONT=$(cat ${_ANSWER})
2022-11-28 08:27:14 +01:00
# get list of 2 sign locale
# ${KEYMAP} | grep -v '...' | grep "^[a-z]"
2023-03-04 19:53:47 +01:00
_KEYMAPS="us English de German es Spanish fr French pt Portuguese OTHER More"
2023-03-05 14:37:59 +01:00
_OTHER_KEYMAPS="be Belarusian bg Bulgarian br Brazil ca Canada cz Czech dk Dansk et Estonian fi Finnish gr Greek hu Hungarian it Italian lt Lithuanian lv Latvian mk Macedonian nl Dutch no Norwegian pl Polish ro Romanian ru Russian sk Slovak sr Serbian sv Swedish uk Ukrainian"
2022-11-28 08:27:14 +01:00
#shellcheck disable=SC2086
2023-03-08 22:42:24 +01:00
_dialog --menu "Select A Keymap Region:" 13 40 7 ${_KEYMAPS} 2>${_ANSWER} || return 1
2023-01-08 08:57:51 +01:00
_KEYMAP=$(cat ${_ANSWER})
if [[ "${_KEYMAP}" == "OTHER" ]]; then
2022-11-28 08:27:14 +01:00
#shellcheck disable=SC2086
2023-03-08 22:42:24 +01:00
_dialog --menu "Select A Keymap Region:" 18 40 12 ${_OTHER_KEYMAPS} 2>${_ANSWER} || return 1
2023-01-08 08:57:51 +01:00
_KEYMAP=$(cat ${_ANSWER})
2022-11-28 08:27:14 +01:00
fi
2023-01-08 08:57:51 +01:00
_KEYMAPS=""
2023-01-09 09:05:40 +01:00
for i in $(${_LIST_MAPS} | grep "^${_KEYMAP}" | grep -v '^carpalx' | grep -v 'defkey' | grep -v 'mac' | grep -v 'amiga' | grep -v 'sun' | grep -v 'atari'); do
2023-01-08 08:57:51 +01:00
_KEYMAPS="${_KEYMAPS} ${i} -"
2022-11-28 08:27:14 +01:00
done
#shellcheck disable=SC2086
2023-03-08 22:42:24 +01:00
_dialog --menu "Select A Keymap Layout:" 14 40 8 ${_KEYMAPS} 2>${_ANSWER} || return 1
2022-11-28 08:27:14 +01:00
#shellcheck disable=SC2086
2023-01-08 08:57:51 +01:00
_KEYMAP=$(cat ${_ANSWER})
2008-10-20 22:39:25 +02:00
}
if [[ -e /tmp/.km-running ]]; then
2011-02-04 18:15:22 +01:00
echo "km already runs on a different console!"
echo "Please remove /tmp/.km-running first to launch tz!"
exit 1
2008-10-20 22:39:25 +02:00
fi
: >/tmp/.km-running
2023-03-08 22:41:13 +01:00
if ! _set_vconsole; then
[[ -e /tmp/.km ]] && rm /tmp/.km
2022-11-28 09:06:52 +01:00
[[ -e /tmp/.km-running ]] && rm /tmp/.km-running
clear
2023-03-08 22:41:13 +01:00
exit 1
2022-11-28 08:56:43 +01:00
fi
2023-03-08 22:57:29 +01:00
[[ -e /tmp/.km ]] && rm /tmp/.km
2023-03-08 22:41:13 +01:00
[[ -e /tmp/.km-running ]] && rm /tmp/.km-running
_do_vconsole
2023-03-08 22:44:22 +01:00
clear
2008-10-20 22:39:25 +02:00
exit 0
2011-02-04 18:15:22 +01:00
# vim: set ts=4 sw=4 et: