Files
kiauh/scripts/ui/main_menu.sh
Yifei Ding 90208f6480 script: Move functions
hove print_kiauh_version and kiauh_update_dialog to general_ui and functions

main_menu performance improvements
2021-11-12 14:44:05 -08:00

62 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
main_menu() {
#print KIAUH update msg if update available
local menu_options=(
"1" "Install"\
"2" "Update"\
"3" "Remove"\
"4" "Advanced Settings"\
"5" "Backup"\
"6" "Settings"\
"7" "Upload Log"\
"8" "Service")
if [ "$KIAUH_UPDATE_AVAIL" = "true" ]; then
kiauh_update_dialog
fi
while true; do
#check install status
print_kiauh_version
klipper_status
moonraker_status
dwc2_status
fluidd_status
mainsail_status
octoprint_status
klipperscreen_status
MoonrakerTelegramBot_status
print_branch
print_msg && clear_msg
local menu_str="Klipper: $KLIPPER_STATUS Branch: $PRINT_BRANCH\n
Moonraker: $MOONRAKER_STATUS\n
Mainsail: $MAINSAIL_STATUS Fluidd: $FLUIDD_STATUS
KlipperScreen: $KLIPPERSCREEN_STATUS Telegram Bot: $MOONRAKER_TELEGRAM_BOT_STATUS
DWC2: $DWC2_STATUS OctoPrint: $OCTOPRINT_STATUS"
local menu
menu=$(whiptail --title "$KIAUH_TITLE $KIAUH_VER" --cancel-button "Finish" --notags --menu "$menu_str\n\nChoose an option:" \
"$KIAUH_WHIPTAIL_NORMAL_HEIGHT" "$KIAUH_WHIPTAIL_NORMAL_WIDTH" 8 "${menu_options[@]}" 3>&1 1>&2 2>&3)
local out=$?
if [ $out -eq 1 ]; then
break
elif [ $out -eq 0 ]; then
case "$menu" in
1) install_menu ;;
2) update_menu ;;
3) remove_menu ;;
4) advanced_menu ;;
5) backup_menu ;;
6) settings_menu ;;
7) upload_selection ;;
8) service_menu;;
esac
else
# Unexpected event, no clue what happened
exit 1
fi
done
echo -e "${green}###### Happy printing! ######${default}"; echo
}