From 09a7bfd97c4bb3131941932aca63b65f1f3f4f67 Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Thu, 24 Feb 2022 15:12:21 -0600 Subject: [PATCH] Allow selection of locale and language --- .gitignore | 3 ++- archtitus.sh | 1 + configs/.dialogrc | 53 ++++++++++++++++++++++++++++++++++++++ scripts/1-setup.sh | 4 +-- scripts/startup.sh | 63 ++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 121 insertions(+), 3 deletions(-) create mode 100644 configs/.dialogrc diff --git a/.gitignore b/.gitignore index a20aba1..afef2e9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ install.conf installlog.txt archnikus.code-workspace -setup.conf \ No newline at end of file +setup.conf +*.log \ No newline at end of file diff --git a/archtitus.sh b/archtitus.sh index 693b248..10e13e5 100755 --- a/archtitus.sh +++ b/archtitus.sh @@ -5,6 +5,7 @@ set -a SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" SCRIPTS_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"/scripts CONFIGS_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"/configs +DIALOGRC=$CONFIGS_DIR/.dialogrc set +a echo -ne " ------------------------------------------------------------------------- diff --git a/configs/.dialogrc b/configs/.dialogrc new file mode 100644 index 0000000..e90f48f --- /dev/null +++ b/configs/.dialogrc @@ -0,0 +1,53 @@ +aspect = 0 +separate_widget = "" +tab_len = 0 +visit_items = OFF +use_shadow = OFF +use_colors = ON + +screen_color = (BLUE,BLACK,OFF) +shadow_color = (BLACK,BLACK,OFF) +dialog_color = (BLUE,BLACK,OFF) +title_color = (WHITE,BLACK,OFF) +border_color = (BLUE,BLACK,OFF) +border2_color = border_color + +button_active_color = (BLACK,BLUE,OFF) +button_inactive_color = (WHITE,BLACK,OFF) +button_key_active_color = (BLACK,BLUE,OFF) +button_key_inactive_color = (RED,BLACK,OFF) +button_label_active_color = (BLACK,BLUE,OFF) +button_label_inactive_color = (WHITE,BLACK,OFF) + +inputbox_color = (WHITE,BLACK,OFF) +inputbox_border_color = (BLACK,BLACK,OFF) + +searchbox_color = (WHITE,BLACK,OFF) +searchbox_title_color = (BLUE,BLACK,OFF) +searchbox_border_color = (WHITE,BLACK,OFF) + +position_indicator_color = (WHITE,BLACK,OFF) + +menubox_color = (BLACK,BLACK,OFF) +menubox_border_color = (BLACK,BLACK,OFF) +menubox_border2_color = menubox_border_color + +item_color = (WHITE,BLACK,OFF) +item_selected_color = (BLACK,BLUE,OFF) + +tag_color = (WHITE,BLACK,OFF) +tag_selected_color = (BLACK,BLUE,OFF) +tag_key_color = (WHITE,BLACK,OFF) +tag_key_selected_color = (BLACK,BLUE,OFF) + +check_color = (WHITE,BLACK,OFF) +check_selected_color = (BLACK,BLUE,OFF) + +uarrow_color = (WHITE,BLACK,OFF) +darrow_color = (WHITE,BLACK,OFF) + +itemhelp_color = (BLACK,WHITE,OFF) + +form_active_text_color = (BLACK,BLUE,OFF) +form_text_color = (WHITE,BLACK,OFF) +form_item_readonly_color = (BLACK,WHITE,OFF) diff --git a/scripts/1-setup.sh b/scripts/1-setup.sh index 9f0e1ad..dac6246 100755 --- a/scripts/1-setup.sh +++ b/scripts/1-setup.sh @@ -47,11 +47,11 @@ echo -ne " Setup Language to US and set locale ------------------------------------------------------------------------- " -sed -i 's/^#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen +echo "$LOCALE" >> /etc/locale.gen locale-gen timedatectl --no-ask-password set-timezone ${TIMEZONE} timedatectl --no-ask-password set-ntp 1 -localectl --no-ask-password set-locale LANG="en_US.UTF-8" LC_TIME="en_US.UTF-8" +localectl --no-ask-password set-locale LANG="$LANG" LANGUAGE="$LANGUAGE" LC_TIME="$LC_TIME" ln -s /usr/share/zoneinfo/${TIMEZONE} /etc/localtime # Set keymaps localectl --no-ask-password set-keymap ${KEYMAP} diff --git a/scripts/startup.sh b/scripts/startup.sh index baf0e75..321f36f 100755 --- a/scripts/startup.sh +++ b/scripts/startup.sh @@ -208,6 +208,56 @@ echo -ne "Your key boards layout: ${keymap} \n" set_option KEYMAP $keymap } +locale() { +declare -a locales + + i=1 #Index counter for adding to array + j=1 #Option menu value generator + + while read line + do + # array[ $i ]=$j + # (( j++ )) + locales[ ($i + 1) ]=$line + (( i=($i+2) )) + + done < <((grep UTF-8 /etc/locale.gen | sed 's/\..*$//' | sed '/@/d' | awk '{print $1}' | uniq | sed 's/#//g')) #consume file path provided as argument + + #Define parameters for menu + terminal=$(tty) #Gather current terminal session for appropriate redirection + height=20 + width=76 + choice_height=16 + back_title="ArchTitus" + title="Locale Selection" + menu="Choose a locale:" + + #Build the menu with variables & dynamic content + while true; do + choice=$(dialog --clear \ + --colors \ + --no-items \ + --backtitle "$back_title" \ + --title "$title" \ + --menu "$menu" \ + $height $width $choice_height \ + "${locales[@]}" \ + 2>&1 >$terminal) + + if [ -z "$choice" ] + then + echo "Nothing selected. Required to continue." + else + echo "Selected $choice"; + set_option LOCALE "\"${choice}.UTF-8 UTF-8\"" + set_option LANG "\"${choice}.UTF-8\"" + set_option LANGUAGE "\"${choice}\"" + set_option LC_TIME "\"${choice}.UTF-8\"" + break + fi + done +} + drivessd () { echo -ne " Is this an ssd? yes/no: @@ -297,12 +347,25 @@ installtype () { set_option INSTALL_TYPE $install_type } +prep() { + echo -ne " + Preparing your system for installation + " + pacman -Sy --noconfirm --needed dialog +} + # More features in future # language (){} # Starting functions clear logo +prep +clear +logo +locale +clear +logo userinfo clear logo