diff --git a/usr/share/archboot/keymap/km b/usr/share/archboot/keymap/km index 493860faf..065a3b97d 100755 --- a/usr/share/archboot/keymap/km +++ b/usr/share/archboot/keymap/km @@ -2,12 +2,12 @@ # written by Tobias Powalowski ANSWER="/tmp/.km" -TITLE="Arch Linux Keymap And Font Setting" +TITLE="Arch Linux Keymap And Console Font Setting" BASEDIR="/usr/share/kbd" abort() { - dodialog yesno "Abort Keymap And Font Setting?" 6 40 || return 0 + DIALOG --yesno "Abort Keymap And Console Font Setting?" 6 40 || return 0 [ -e /tmp/.km ] && rm -f /tmp/.km [ -e /tmp/.keymap ] && rm -f /tmp/.keymap [ -e /tmp/.font ] && rm -f /tmp/.font @@ -16,41 +16,25 @@ abort() exit 0 } -dodialog() -{ - # use this for msgbox, inputbox, yesno, infobox - # - # dodialog [height] [width] [other] - # 26/3/06: added an option so that if [other] is default=no - # the dialog will default to no - # the new dialog's auto-sizing is pretty dumb, we can't trust it - height=12 - width=65 - if [ "$3" != "" ]; then - height=$3 - fi - if [ "$4" != "" ]; then - width=$4 - fi - if [ "$5" == "default=no" ]; then - dialog --defaultno --backtitle "$TITLE" --aspect 15 --$1 "$2" $height $width - - else - dialog --backtitle "$TITLE" --aspect 15 --$1 "$2" $height $width $5 - fi +# DIALOG() +# an el-cheapo dialog wrapper +# +# parameters: see dialog(1) +# returns: whatever dialog did +DIALOG() { + dialog --backtitle "$TITLE" --aspect 15 "$@" + return $? } -domenu() +error_kmset() { - menutype=$1 ; shift - text=$1 ; shift - height=$1 ; shift - width=$1 ; shift - mheight=$1 ; shift - - dialog --cancel-label "Skip" --$menutype "$text" $height $width $mheight $* + DIALOG --msgbox "An error occured, your current keymap was not changed." 0 0 } +error_consoleset() +{ + DIALOG --msgbox "An error occured, your current consolefont was not changed." 0 0 +} dokeymap() { echo "Scanning for keymaps..." @@ -58,14 +42,15 @@ dokeymap() { for i in $(find $BASEDIR/keymaps -follow -name "*.gz" | sed 's|^.*/||g' | sort); do KEYMAPS="$KEYMAPS $i -" done - domenu menu "Select A Keymap" 22 60 16 $KEYMAPS 2>$ANSWER + DIALOG --menu "Select A Keymap" 22 60 16 $KEYMAPS 2>$ANSWER || DIALOG --msgbox "Aborting, your current keymap was not changed." 0 0 keymap=$(cat $ANSWER) echo $keymap > /tmp/.keymap if [ "$keymap" ]; then echo "Loading keymap: $keymap" #loadkeys -q $BASEDIR/keymaps/$keymap - loadkeys -q $keymap + loadkeys -q $keymap || error_kmset fi +S_NEXTITEM=2 } doconsolefont() { @@ -75,7 +60,7 @@ doconsolefont() { for i in $(find $BASEDIR/consolefonts -maxdepth 1 ! -name '*.cp.gz' -name "*.gz" | sed 's|^.*/||g' | sort); do FONTS="$FONTS $i -" done - domenu menu "Select A Console Font" 22 60 16 $FONTS 2>$ANSWER + DIALOG --menu "Select A Console Font" 22 60 16 $FONTS 2>$ANSWER || DIALOG --msgbox "Aborting, your current consolefont was not changed." 0 0 font=$(cat $ANSWER) echo $font > /tmp/.font if [ "$font" ]; then @@ -88,7 +73,11 @@ doconsolefont() { fi done [ -e /dev/ttys0 ] && setfont $BASEDIR/consolefonts/$font -C /dev/ttyS0 + if [ $? -gt 0 ]; then + error_consoleset + fi fi +S_NEXTITEM=3 } mainmenu() { @@ -97,7 +86,7 @@ mainmenu() { else DEFAULT="" fi - dialog $DEFAULT --backtitle "$TITLE" --title " MAIN MENU " \ + DIALOG $DEFAULT --backtitle "$TITLE" --title " MAIN MENU " \ --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" \ @@ -149,7 +138,7 @@ if [ -e /tmp/.km-running ]; then fi : >/tmp/.km-running -while $(/bin/true); do +while true; do mainmenu done diff --git a/usr/share/archboot/tz/tz b/usr/share/archboot/tz/tz index ed083c8f0..df884f7de 100755 --- a/usr/share/archboot/tz/tz +++ b/usr/share/archboot/tz/tz @@ -2,12 +2,12 @@ # written by Tobias Powalowski ANSWER="/tmp/.tz" -TITLE="Arch Linux Time Setting" +TITLE="Arch Linux Time And Date Setting" BASEDIR="/usr/share/zoneinfo" abort() { - dodialog yesno "Abort Time Setting?" 6 40 || return 0 + DIALOG --yesno "Abort Time And Date Setting?" 6 40 || return 0 [ -e /tmp/.timezone ] && rm -f /tmp/.timezone [ -e /tmp/.hardwareclock ] && rm -f /tmp/.hardwareclock [ -e /tmp/.tz ] && rm -f /tmp/.tz @@ -18,39 +18,14 @@ abort() exit 0 } -dodialog() -{ - # use this for msgbox, inputbox, yesno, infobox - # - # dodialog [height] [width] [other] - # 26/3/06: added an option so that if [other] is default=no - # the dialog will default to no - # the new dialog's auto-sizing is pretty dumb, we can't trust it - height=12 - width=65 - if [ "$3" != "" ]; then - height=$3 - fi - if [ "$4" != "" ]; then - width=$4 - fi - if [ "$5" == "default=no" ]; then - dialog --defaultno --backtitle "$TITLE" --aspect 15 --$1 "$2" $height $width - - else - dialog --backtitle "$TITLE" --aspect 15 --$1 "$2" $height $width $5 - fi -} - -domenu() -{ - menutype=$1 ; shift - text=$1 ; shift - height=$1 ; shift - width=$1 ; shift - mheight=$1 ; shift - - dialog --cancel-label "Skip" --$menutype "$text" $height $width $mheight $* +# DIALOG() +# an el-cheapo dialog wrapper +# +# parameters: see dialog(1) +# returns: whatever dialog did +DIALOG() { + dialog --backtitle "$TITLE" --aspect 15 "$@" + return $? } dohwclock() { @@ -76,72 +51,74 @@ 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 -domenu menu "Please Select A Region:" 22 60 16 $REGIONS 2>$ANSWER && SET_REGION="1" +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 - domenu menu "Please Select A Timezone:" 22 60 16 $ZONES 2>$ANSWER && SET_ZONE="1" + DIALOG --menu "Please Select A Timezone:" 22 60 16 $ZONES 2>$ANSWER && SET_ZONE="1" zone=$(cat $ANSWER) if [ "${SET_ZONE}" = "1" ]; then - dodialog infobox "Setting Timezone to $region/$zone ..." + 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 else - dodialog msgbox "Skipping Region and Timezone, else please select a Timezone!" + DIALOG --msgbox "Skipping region and timezone, please select a timezone." 0 0 fi else - dodialog msgbox "Skipping Region and Timezone, else please select correct Region first!" + DIALOG --msgbox "Skipping region and timezone, please select a region first." 0 0 fi S_NEXTITEM="2" } +error_timeset() +{ + DIALOG --msgbox "Aborting, your current time was not changed." 0 0 +} + dotimeset() { SET_TIME="" USE_NTPDATE="" HARDWARECLOCK="" if [ ! -s /tmp/.timezone ]; then - dodialog msgbox "You have not selected a region and timezone,\nplease select one!" + DIALOG --msgbox "You have to select a region and timezone." 0 0 S_NEXTITEM="1" return 1 fi -dodialog yesno "Do you want to use UTC for your clock?\n\nIf you choose 'YES' UTC (recommended default) is used,\nwhich ensures daylightsaving is set automatically.\n\nIf you choose 'NO' Localtime is used,\nwhich means the system will not change the time.\nLocaltime is also prefered on dualboot machines,\nwhich also run Windows, because UTC confuses it." 15 65 && HARDWARECLOCK="UTC" -dodialog infobox "Syncing hardwareclock to systemclock ..." +DIALOG --yesno "Do you want to use UTC for your clock?\n\nIf you choose 'YES' UTC (recommended default) is used,\nwhich ensures daylightsaving is set automatically.\n\nIf you choose 'NO' Localtime is used, which means\nthe system will not change the time automatically.\nLocaltime is also prefered on dualboot machines,\nwhich also run Windows, because UTC confuses it." 15 65 && HARDWARECLOCK="UTC" +DIALOG --infobox "Syncing hardwareclock to systemclock ..." 0 0 HWCLOCK_PARAMS="--hctosys" dohwclock -dodialog yesno "Your current time is:\n$(date)\n\nDo you want to change it?" "" "" && SET_TIME="1" +DIALOG --yesno "Your current time and date is:\n$(date)\n\nDo you want to change it?" 0 0 && SET_TIME="1" if [ "${SET_TIME}" = "1" ]; then - [ $(which ntpdate) ] && dodialog yesno "'ntpdate' was detected on your system.\n\nDo you want to use 'ntpdate' for syncing your clock,\nby using the internet clock pool?\n(You need a working internet connection for doing this!)" "" "" default=no && USE_NTPDATE="1" + [ $(which ntpdate) ] && DIALOG --defaultno --yesno "'ntpdate' was detected on your system.\n\nDo you want to use 'ntpdate' for syncing your clock,\nby using the internet clock pool?\n(You need a working internet connection for doing this!)" 0 0 && USE_NTPDATE="1" if [ "${USE_NTPDATE}" = "1" ]; then if [ ! $(ntpdate pool.ntp.org) ]; then - dodialog msgbox "An error has occured, time was not changed!" + DIALOG --msgbox "An error has occured, time was not changed!" 0 0 S_NEXTITEM="2" return 1 fi - dodialog msgbox "Synced clock with internet pool successfully.\n\nYour current time is now:\n$(date)" + DIALOG --msgbox "Synced clock with internet pool successfully.\n\nYour current time is now:\n$(date)" 0 0 else - dodialog inputbox "Your current time is:\n$(date)\n\nSyntax of your current time is:\n$(date +%m%d%H%M%y)\nMMDDhhmmYY\n\nPlease enter your correct time below,\naccording to the syntax.\n " 17 60 "" 2>$ANSWER || return 1 - if [ ! $(cat $ANSWER) = "" ]; then - if [ ! $(date $(cat $ANSWER)) ]; then - dodialog msgbox "An error occured during time setting,\ncurrent time was not changed!" - S_NEXTITEM="2" - return 1 - fi - else - dodialog msgbox "You entered nothing, current time was not changed!" - S_NEXTITEM="2" - return 1 - fi - dodialog infobox "Syncing systemclock to hardwareclock ..." + # 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) + 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) + local _time="$(cat $ANSWER)" + # save the time + # DD/MM/YYYY hh:mm:ss -> YYYY-MM-DD hh:mm:ss + local _datetime="$(echo "$_date" "$_time" | sed 's#\(..\)/\(..\)/\(....\) \(..\):\(..\):\(..\)#\3-\2-\1 \4:\5:\6#g')" + date -s "$_datetime" + DIALOG --infobox "Syncing systemclock to hardwareclock ..." 0 0 HWCLOCK_PARAMS="--systohc" dohwclock - dodialog msgbox "Your current time is now:\n$(date)" + DIALOG --msgbox "Your current time is now:\n$(date)" 0 0 fi else - dodialog msgbox "Current time was not changed!" + DIALOG --msgbox "Current time was not changed!" 0 0 fi S_NEXTITEM="3" } @@ -152,10 +129,10 @@ mainmenu() { else DEFAULT="" fi - dialog $DEFAULT --backtitle "$TITLE" --title " MAIN MENU " \ + DIALOG $DEFAULT --backtitle "$TITLE" --title " MAIN MENU " \ --menu "Use the UP and DOWN arrows to navigate menus. Use TAB to switch between buttons and ENTER to select." 15 55 8 \ "1" "Select Region and Timezone" \ - "2" "Set Date and Time" \ + "2" "Set Time and Date" \ "3" "Exit" 2>$ANSWER case $(cat $ANSWER) in "1") @@ -200,7 +177,7 @@ if [ -e /tmp/.tz-running ]; then fi : >/tmp/.tz-running -while $(/bin/true); do +while true; do mainmenu done