#!/bin/bash
PIS_SBIN="${PIS_SBIN:-/sbin}"
if [ -z "${PIS_LIBDIR:-}" ]; then
    case "$(uname -m)" in x86_64) PIS_LIBDIR=/usr/lib64/pis ;; *) PIS_LIBDIR=/usr/lib/pis ;; esac
fi
. "$PIS_LIBDIR/pis_lib" 2>/dev/null || . "$(dirname "$0")/pis_lib" || exit 1
pis_init || exit 1
while true; do
    current_locale="$(pis_state_read language_country)"; current_keymap="$(pis_state_read keyboard_map)"
    choice=$(dialog --stdout --backtitle "$PIS_BACKTITLE" --title "System Locale" \
        --menu "Current locale: ${current_locale:-not recorded}\nCurrent keymap: ${current_keymap:-not recorded}" 0 0 0 \
        language "Set system language and country" \
        keyboard "Set console keyboard map") || exit 0
    case "$choice" in
        language) "$PIS_SBIN/pis_locale_set_language_country" ;;
        keyboard) "$PIS_SBIN/pis_locale_set_keyboard_map" ;;
    esac
done
