use case to dispatch internationalisation menu functions

This commit is contained in:
Alex Bradbury 2013-05-22 20:17:32 +01:00
parent 3d725a80fa
commit c85396d754
1 changed files with 13 additions and 8 deletions

View File

@ -178,17 +178,17 @@ do_change_pass() {
whiptail --msgbox "Password changed successfully" 20 60 1
}
do_I3() { # Keyboard
do_configure_keyboard() {
dpkg-reconfigure keyboard-configuration &&
printf "Reloading keymap. This may take a short while\n" &&
invoke-rc.d keyboard-setup start
}
do_I1() { # Locale
do_change_locale() {
dpkg-reconfigure locales
}
do_I2() { # Timezone
do_change_timezone() {
dpkg-reconfigure tzdata
}
@ -526,15 +526,20 @@ fi
do_internationalisation_menu() {
FUN=$(whiptail --title "Raspberry Pi Software Configuration Tool (raspi-config)" --menu "Internationalisation Options" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT --cancel-button Back --ok-button Select \
"I1 Change Locale" "Set up language and regional settings to match your location" \
"I2 Change Timezone" "Set up timezone to match your location" \
"I3 Change Keyboard Layout" "Set the keyboard layout to match your keyboard" \
3>&1 1>&2 2>&3)
"I1 Change Locale" "Set up language and regional settings to match your location" \
"I2 Change Timezone" "Set up timezone to match your location" \
"I3 Change Keyboard Layout" "Set the keyboard layout to match your keyboard" \
3>&1 1>&2 2>&3)
RET=$?
if [ $RET -eq 1 ]; then
return 0
elif [ $RET -eq 0 ]; then
"do_$(echo $FUN | head -c 2)" || whiptail --msgbox "There was an error running option $FUN" 20 60 1
case "$FUN" in
I1\ *) do_change_locale ;;
I2\ *) do_change_timezone ;;
I3\ *) do_configure_keyboard ;;
*) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;;
esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1
fi
}