From 0fca45b51b714f72c22f5cd2e559dd1fdbbd8cfb Mon Sep 17 00:00:00 2001 From: Tobias Powalowski Date: Sat, 31 Jan 2009 19:44:09 +0100 Subject: [PATCH] 'fixed km, tz menu switching' --- usr/share/archboot/installer/setup | 4 +- usr/share/archboot/keymap/km | 35 +++++++++++---- usr/share/archboot/tz/tz | 68 +++++++++++++++++++----------- 3 files changed, 71 insertions(+), 36 deletions(-) diff --git a/usr/share/archboot/installer/setup b/usr/share/archboot/installer/setup index 06fd312ba..54eb3d458 100755 --- a/usr/share/archboot/installer/setup +++ b/usr/share/archboot/installer/setup @@ -1497,7 +1497,7 @@ select_source() set_clock() { if [ -e /usr/bin/tz ]; then - tz + tz --setup else DIALOG --msgbox "Error:\ntz script not found, aborting clock setting" 0 0 fi @@ -1507,7 +1507,7 @@ set_clock() set_keyboard() { if [ -e /usr/bin/km ]; then - km + km --setup else DIALOG --msgbox "Error:\nkm script not found, aborting keyboard and console setting" 0 0 fi diff --git a/usr/share/archboot/keymap/km b/usr/share/archboot/keymap/km index 5919af417..b104658be 100755 --- a/usr/share/archboot/keymap/km +++ b/usr/share/archboot/keymap/km @@ -5,6 +5,12 @@ ANSWER="/tmp/.km" TITLE="Arch Linux Keymap And Console Font Setting" BASEDIR="/usr/share/kbd" +if [ "$1" = "--setup" ]; then + EXIT="Return to Main Menu" +else + EXIT="Exit" +fi + abort() { DIALOG --yesno "Abort Keymap And Console Font Setting?" 6 40 || return 0 @@ -37,13 +43,18 @@ dokeymap() { for i in $(find $BASEDIR/keymaps -follow -name "*.gz" | sed 's|^.*/||g' | sort); do KEYMAPS="$KEYMAPS $i -" done - DIALOG --menu "Select A Keymap" 22 60 16 $KEYMAPS 2>$ANSWER || DIALOG --msgbox "Aborting, your current keymap was not changed." 0 0 + DIALOG --menu "Select A Keymap" 22 60 16 $KEYMAPS 2>$ANSWER || CANCEL="1" + if [ "$CANCEL" = "1" ]; then + DIALOG --msgbox "Aborting, your current keymap was not changed." 0 0 + S_NEXTITEM="1" + return 1 + fi keymap=$(cat $ANSWER) echo $keymap > /tmp/.keymap if [ "$keymap" ]; then - echo "Loading keymap: $keymap" + DIALOG --infobox "Loading keymap: $keymap" 0 0 #loadkeys -q $BASEDIR/keymaps/$keymap - loadkeys -q $keymap || error_kmset + loadkeys -q $keymap > /dev/null 2>&1 || error_kmset fi S_NEXTITEM=2 } @@ -55,19 +66,25 @@ doconsolefont() { for i in $(find $BASEDIR/consolefonts -maxdepth 1 ! -name '*.cp.gz' -name "*.gz" | sed 's|^.*/||g' | sort); do FONTS="$FONTS $i -" done - DIALOG --menu "Select A Console Font" 22 60 16 $FONTS 2>$ANSWER || DIALOG --msgbox "Aborting, your current consolefont was not changed." 0 0 + CANCEL="" + DIALOG --menu "Select A Console Font" 22 60 16 $FONTS 2>$ANSWER || CANCEL=1 + if [ "$CANCEL" = "1" ]; then + DIALOG --msgbox "Aborting, your current consolefont was not changed." 0 0 + S_NEXTITEM="2" + return 1 + fi font=$(cat $ANSWER) echo $font > /tmp/.font if [ "$font" ]; then - echo "Loading font: $font" + DIALOG --infobox "Loading font: $font" 0 0 for i in $(seq 1 6); do if [ -d /dev/vc ]; then - setfont $BASEDIR/consolefonts/$font -C /dev/vc/${i} + setfont $BASEDIR/consolefonts/$font -C /dev/vc/${i} > /dev/null 2>&1 else - setfont $BASEDIR/consolefonts/$font -C /dev/tty${i} + setfont $BASEDIR/consolefonts/$font -C /dev/tty${i} > /dev/null 2>&1 fi done - [ -e /dev/ttyS0 ] && setfont $BASEDIR/consolefonts/$font -C /dev/ttyS0 + [ -e /dev/ttyS0 ] && setfont $BASEDIR/consolefonts/$font -C /dev/ttyS0 > /dev/null 2>&1 fi S_NEXTITEM=3 } @@ -82,7 +99,7 @@ mainmenu() { --menu "Use the UP and DOWN arrows to navigate menus. Use TAB to switch between buttons and ENTER to select." 15 55 8 \ "1" "Set Keymap" \ "2" "Set Consolefont" \ - "3" "Exit" 2>$ANSWER + "3" "$EXIT" 2>$ANSWER case $(cat $ANSWER) in "1") dokeymap diff --git a/usr/share/archboot/tz/tz b/usr/share/archboot/tz/tz index df884f7de..810c435b2 100755 --- a/usr/share/archboot/tz/tz +++ b/usr/share/archboot/tz/tz @@ -5,6 +5,12 @@ ANSWER="/tmp/.tz" TITLE="Arch Linux Time And Date Setting" BASEDIR="/usr/share/zoneinfo" +if [ "$1" = "--setup" ]; then + EXIT="Return to Main Menu" +else + EXIT="Exit" +fi + abort() { DIALOG --yesno "Abort Time And Date Setting?" 6 40 || return 0 @@ -46,32 +52,35 @@ hwclock $HWCLOCK_PARAMS dotimezone () { REGIONS="" -SET_REGION="" SET_ZONE="" for i in $(grep ^[A-Z] $BASEDIR/zone.tab | cut -f 3 | sed -e 's#/.*##g'| sort -u); do REGIONS="$REGIONS $i -" done -DIALOG --menu "Please Select A Region:" 22 60 16 $REGIONS 2>$ANSWER && SET_REGION="1" -region=$(cat $ANSWER) -if [ "${SET_REGION}" = "1" ]; then - for i in $(grep ^[A-Z] $BASEDIR/zone.tab | grep $region/ | cut -f 3 | sed -e "s#$region/##g"| sort -u); do - ZONES="$ZONES $i -" - done - DIALOG --menu "Please Select A Timezone:" 22 60 16 $ZONES 2>$ANSWER && SET_ZONE="1" - zone=$(cat $ANSWER) - if [ "${SET_ZONE}" = "1" ]; then - DIALOG --infobox "Setting Timezone to $region/$zone ..." 0 0 - echo $region/$zone > /tmp/.timezone - [ -e /etc/localtime ] && rm -f /etc/localtime - cp $BASEDIR/$region/$zone /etc/localtime - dohwclock +while ! [ "$SET_ZONE" = "1" ]; do + SET_REGION="" + DIALOG --menu "Please Select A Region:" 22 60 16 $REGIONS 2>$ANSWER && SET_REGION="1" + region=$(cat $ANSWER) + if [ "${SET_REGION}" = "1" ]; then + ZONES="" + for i in $(grep ^[A-Z] $BASEDIR/zone.tab | grep $region/ | cut -f 3 | sed -e "s#$region/##g"| sort -u); do + ZONES="$ZONES $i -" + done + DIALOG --menu "Please Select A Timezone:" 22 60 16 $ZONES 2>$ANSWER && SET_ZONE="1" + zone=$(cat $ANSWER) + if [ "${SET_ZONE}" = "1" ]; then + DIALOG --infobox "Setting Timezone to $region/$zone ..." 0 0 + echo $region/$zone > /tmp/.timezone + [ -e /etc/localtime ] && rm -f /etc/localtime + cp $BASEDIR/$region/$zone /etc/localtime + dohwclock + S_NEXTITEM="2" + fi else - DIALOG --msgbox "Skipping region and timezone, please select a timezone." 0 0 + DIALOG --msgbox "Skipping region and timezone." 0 0 + S_NEXTITEM="1" + break fi -else - DIALOG --msgbox "Skipping region and timezone, please select a region first." 0 0 -fi -S_NEXTITEM="2" +done } error_timeset() @@ -84,7 +93,7 @@ SET_TIME="" USE_NTPDATE="" HARDWARECLOCK="" if [ ! -s /tmp/.timezone ]; then - DIALOG --msgbox "You have to select a region and timezone." 0 0 + DIALOG --msgbox "You have to select a region and timezone first." 0 0 S_NEXTITEM="1" return 1 fi @@ -104,9 +113,20 @@ if [ "${SET_TIME}" = "1" ]; then DIALOG --msgbox "Synced clock with internet pool successfully.\n\nYour current time is now:\n$(date)" 0 0 else # display and ask to set date/time - dialog --calendar "Set the date.\nUse to navigate and arrow keys to change values." 0 0 0 0 0 2> $ANSWER || (error_timeset; return 1) + CANCEL="" + dialog --calendar "Set the date.\nUse to navigate and arrow keys to change values." 0 0 0 0 0 2> $ANSWER || CANCEL="1" + if [ "$CANCEL" = "1" ]; then + error_timeset + S_NEXTITEM="2" + return 1 + fi local _date="$(cat $ANSWER)" - dialog --timebox "Set the time.\nUse to navigate and up/down to change values." 0 0 2> $ANSWER || (error_timeset; return 1) + dialog --timebox "Set the time.\nUse to navigate and up/down to change values." 0 0 2> $ANSWER || CANCEL="1" + if [ "$CANCEL" = "1" ]; then + error_timeset + S_NEXTITEM="2" + return 1 + fi local _time="$(cat $ANSWER)" # save the time # DD/MM/YYYY hh:mm:ss -> YYYY-MM-DD hh:mm:ss @@ -117,8 +137,6 @@ if [ "${SET_TIME}" = "1" ]; then dohwclock DIALOG --msgbox "Your current time is now:\n$(date)" 0 0 fi -else - DIALOG --msgbox "Current time was not changed!" 0 0 fi S_NEXTITEM="3" }