@@ -42,7 +42,7 @@ function usage_and_exit()
4242 W_ " ${MSG} "
4343 fi
4444 echo
45- echo " Where :"
45+ echo " Arguments :"
4646 echo " --help Displays this message and exits."
4747 echo " --help command Displays a help message for the specified command, then exits."
4848 echo " --debug Displays debugging information."
@@ -568,9 +568,9 @@ function run_command()
568568# ####
569569# Prompt for a command or argument from a list.
570570if [[ ${ON_TTY} == " true" ]]; then
571- WT_LINES =$( tput lines 2> /dev/null )
571+ T_LINES =$( tput lines 2> /dev/null )
572572fi
573- WT_LINES =" ${WT_LINES :- 24} "
573+ T_LINES =" ${T_LINES :- 24} "
574574
575575function prompt()
576576{
@@ -579,17 +579,37 @@ function prompt()
579579 local OPTIONS=(" ${@ } " )
580580 local NUM_OPTIONS=$(( ${# OPTIONS[@]} / 2 ))
581581
582- # whiptail's menubox has:
583- # 4 lines at top
584- # then the menu (NUM_OPTIONS lines)
585- # 2 blank lines
586- # 1 "<Ok> / <Cancel>" line
587- # 2 blank lines
588- # If all that doesn't fit in the terminal windows, whiptail does NOT scroll.
582+ if true ; then
583+ D_TITLE=" *** Allsky Configuration ***"
584+ D_HEIGHT=$(( 5 + NUM_OPTIONS ))
585+ D_WIDTH=" 85"
586+ D_MENU_HEIGHT=" ${NUM_OPTIONS} "
587+ local OPT=" $( dialog --no-tags --title " ${D_TITLE} " \
588+ --default-item " ${DEFAULT_MENU_ITEM} " \
589+ " --menu" " ${PROMPT} " \
590+ " ${T_LINES} " " ${D_WIDTH} " " ${D_MENU_HEIGHT} " " ${OPTIONS[@]} " 3>&1 1>&2 2>&3 ) "
591+ local RET=$?
592+ if [[ ${RET} -ne 0 ]]; then
593+ E_ " \n${ME} : 'dialog' failed." >&2
594+ exit 2
595+ else
596+ echo " ${OPT} "
597+ return " ${RET} "
598+ fi
599+
600+ else
601+ # whiptail's menubox has:
602+ # 4 lines at top
603+ # then the menu (NUM_OPTIONS lines)
604+ # 2 blank lines
605+ # 1 "<Ok> / <Cancel>" line
606+ # 2 blank lines
607+ # If all that doesn't fit in the terminal windows, whiptail does NOT scroll.
589608 local LINES=$(( 4 + NUM_OPTIONS + 2 + 1 + 2 ))
590- if [[ ${LINES} -ge ${WT_LINES} ]]; then
609+
610+ if [[ ${LINES} -ge ${T_LINES} ]]; then
591611 echo " Please resize your window to at least $(( LINES + 1 )) lines."
592- echo " It is only ${WT_LINES } lines now."
612+ echo " It is only ${T_LINES } lines now."
593613 return 1
594614 fi >&2
595615
@@ -604,6 +624,7 @@ function prompt()
604624 echo " ${OPT} "
605625 return " ${RET} "
606626 fi
627+ fi
607628}
608629
609630
@@ -633,7 +654,7 @@ function L()
633654 local NAME=" ${1} "
634655
635656 local NUM=" $( printf " %2d" " ${N} " ) "
636- echo -e " ${NUM} . ${NAME} "
657+ echo -e " ${NUM} . ${NAME} "
637658}
638659
639660
@@ -699,103 +720,106 @@ if [[ -z ${FUNCTION_TO_EXECUTE} ]]; then
699720 CMDS+=(" header" " Commands to Display Information" )
700721
701722 (( N++ )) ; C=" get_startrails_info"
702- CMDS+=(" ${C} " " $( L " Get information on startrails image brightness (${C} )" ) " )
723+ CMDS+=(" ${C} " " $( L " Get information on startrails image brightness (${C} )" ) " )
703724
704725 DEFAULT_MENU_ITEM=" ${C} " # Must be 1st item
705726
706727 (( N++ )) ; C=" show_start_times"
707- CMDS+=(" ${C} " " $( L " Show daytime and nighttime start times (${C} )" ) " )
728+ CMDS+=(" ${C} " " $( L " Show daytime and nighttime start times (${C} )" ) " )
708729
709730 (( N++ )) ; C=" show_supported_cameras"
710- CMDS+=(" ${C} " " $( L " Show supported cameras (${C} )" ) " )
731+ CMDS+=(" ${C} " " $( L " Show supported cameras (${C} )" ) " )
711732
712733 (( N++ )) ; C=" show_connected_cameras"
713- CMDS+=(" ${C} " " $( L " Show connected cameras (${C} )" ) " )
734+ CMDS+=(" ${C} " " $( L " Show connected cameras (${C} )" ) " )
714735
715736 (( N++ )) ; C=" new_rpi_camera_info"
716- CMDS+=(" ${C} " " $( L " Collect information for new RPi camera (${C} )" ) " )
737+ CMDS+=(" ${C} " " $( L " Collect information for new RPi camera (${C} )" ) " )
717738
718739 (( N++ )) ; C=" show_installed_locales"
719- CMDS+=(" ${C} " " $( L " Show the locales installed on the Pi (${C} )" ) " )
740+ CMDS+=(" ${C} " " $( L " Show the locales installed on the Pi (${C} )" ) " )
720741
721742 (( N++ )) ; C=" get_filesystems"
722- CMDS+=(" ${C} " " $( L " Determine where a secodary storage device is (${C} )" ) " )
743+ CMDS+=(" ${C} " " $( L " Determine where a secodary storage device is (${C} )" ) " )
723744
724745 (( N++ )) ; C=" encoders"
725- CMDS+=(" ${C} " " $( L " Show list of timelapse encoders available (${C} )" ) " )
746+ CMDS+=(" ${C} " " $( L " Show available timelapse encoders (${C} )" ) " )
726747
727748 (( N++ )) ; C=" pix_fmts"
728- CMDS+=(" ${C} " " $( L " Show list of timelapse pixel formats available (${C} )" ) " )
749+ CMDS+=(" ${C} " " $( L " Show available of timelapse pixel formats (${C} )" ) " )
729750
730751
731752# ####
732753 CMDS+=(" header" " Commands to Create Test Images or Videos" )
733754
734755 (( N++ )) ; C=" compare_timelapse"
735- CMDS+=(" ${C} " " $( L " Create multiple timelapse videos (${C} )" ) " )
756+ CMDS+=(" ${C} " " $( L " Create multiple timelapse videos (${C} )" ) " )
736757
737758 (( N++ )) ; C=" compare_startrails"
738- CMDS+=(" ${C} " " $( L " Create multiple startrails (${C} )" ) " )
759+ CMDS+=(" ${C} " " $( L " Create multiple startrails (${C} )" ) " )
739760
740761 (( N++ )) ; C=" compare_stretches"
741- CMDS+=(" ${C} " " $( L " Create multiple stretched images (${C} )" ) " )
762+ CMDS+=(" ${C} " " $( L " Create multiple stretched images (${C} )" ) " )
742763
743764
744765# ####
745766 CMDS+=(" header" " Commands to Change Pi Settings" )
746767
747768 (( N++ )) ; C=" change_swap"
748- CMDS+=(" ${C} " " $( L " Add swap space or change size (${C} )" ) " )
769+ CMDS+=(" ${C} " " $( L " Add swap space or change size (${C} )" ) " )
749770
750771 (( N++ )) ; C=" change_tmp"
751- CMDS+=(" ${C} " " $( L " Move ~/allsky/tmp to memory or change size (${C} )" ) " )
772+ CMDS+=(" ${C} " " $( L " Move ~/allsky/tmp to memory or change size (${C} )" ) " )
752773
753774 (( N++ )) ; C=" samba"
754- CMDS+=(" ${C} " " $( L " Simplify copying files to/from the Pi (${C} )" ) " )
775+ CMDS+=(" ${C} " " $( L " Simplify copying files to/from the Pi (${C} )" ) " )
755776
756777
757778# ####
758779 CMDS+=(" header" " Troubleshooting Commands" )
759780
760781 (( N++ )) ; C=" bad_images_info"
761- CMDS+=(" ${C} " " $( L " Display information on 'bad' images (${C} )" ) " )
782+ CMDS+=(" ${C} " " $( L " Display information on 'bad' images (${C} )" ) " )
762783
763784 (( N++ )) ; C=" check_post_data"
764- CMDS+=(" ${C} " " $( L " Troubleshoot the 'data.json is X days old' message (${C} )" ) " )
785+ CMDS+=(" ${C} " " $( L " Troubleshoot 'data.json' messages (${C} )" ) " )
765786
766787 (( N++ )) ; C=" compare_paths"
767- CMDS+=(" ${C} " " $( L " Compare upload and Website paths (${C} )" ) " )
788+ CMDS+=(" ${C} " " $( L " Compare upload and Website paths (${C} )" ) " )
768789
769790 (( N++ )) ; C=" test_upload"
770- CMDS+=(" ${C} " " $( L " Test uploading a file (${C} )" ) " )
791+ CMDS+=(" ${C} " " $( L " Test uploading a file (${C} )" ) " )
771792
772793
773794
774795# ####
775796 CMDS+=(" header" " Misc. Commands" )
776797
777798 (( N++ )) ; C=" manage_modules"
778- CMDS+=(" ${C} " " $( L " Install or uninstall modules. (${C} )" ) " )
799+ CMDS+=(" ${C} " " $( L " Install or uninstall modules. (${C} )" ) " )
779800
780801 (( N++ )) ; C=" move_images"
781802 (( N++ )) ; C=" check_allsky"
782- CMDS+=(" ${C} " " $( L " Check Allsky for setting errors and warnings (${C} )" ) " )
803+ CMDS+=(" ${C} " " $( L " Check Allsky for setting errors and warnings (${C} )" ) " )
783804
784805 (( N++ )) ; C=" move_images"
785- CMDS+=(" ${C} " " $( L " Move ~/allsky/images to a different location (${C} )" ) " )
806+ CMDS+=(" ${C} " " $( L " Move ~/allsky/images to a different location (${C} )" ) " )
786807
787808 (( N++ )) ; C=" prepare_logs"
788- CMDS+=(" ${C} " " $( L " Prepare log files for troubleshooting (${C} )" ) " )
809+ CMDS+=(" ${C} " " $( L " Prepare log files for troubleshooting (${C} )" ) " )
789810
790811 (( N++ )) ; C=" recreate_files"
791- CMDS+=(" ${C} " " $( L " Recreate various files after a 'git pull' (${C} )" ) " )
812+ CMDS+=(" ${C} " " $( L " Recreate various files after a 'git pull' (${C} )" ) " )
792813
793814 # #### Prompt
794815 # If the user selects "Cancel" prompt() returns 1 and we exit the loop.
795816 P=" ${PROMPT} "
796817 while COMMAND=" $( prompt " ${P} " " ${CMDS[@]} " ) "
797818 do
798- [[ -z ${COMMAND} ]] && exit 0
819+ if [[ -z ${COMMAND} ]]; then
820+ [[ ${ON_TTY} == " true" ]] && clear
821+ exit 0
822+ fi
799823
800824 if [[ ${COMMAND} == " header" ]]; then
801825 # There isn't a way in whiptail to group items so we fake it.
@@ -805,6 +829,7 @@ if [[ -z ${FUNCTION_TO_EXECUTE} ]]; then
805829 P=" ${PROMPT} " # restore prompt
806830
807831
832+ [[ ${ON_TTY} == " true" ]] && clear
808833 run_command " ${COMMAND} "
809834 RET=$?
810835
0 commit comments