From 00fa372e0c694cb071e737e3e0ed14494eed91cb Mon Sep 17 00:00:00 2001 From: Yifei Ding Date: Sat, 13 Nov 2021 00:42:23 -0800 Subject: [PATCH] script: multi-layer install menu --- scripts/ui/install_interface_menu.sh | 36 +++++++++++++ scripts/ui/install_menu.sh | 76 ++++++++++------------------ scripts/ui/install_other_menu.sh | 33 ++++++++++++ 3 files changed, 95 insertions(+), 50 deletions(-) create mode 100755 scripts/ui/install_interface_menu.sh create mode 100755 scripts/ui/install_other_menu.sh diff --git a/scripts/ui/install_interface_menu.sh b/scripts/ui/install_interface_menu.sh new file mode 100755 index 0000000..d5409ff --- /dev/null +++ b/scripts/ui/install_interface_menu.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# +# Brief description of your script + +install_interface_menu(){ + + local menu_options=( + "1" "Mainsail - lightweight & responsive web interface for Klipper" + "2" "Fluidd - a free and open-source Klipper web interface for managing your 3d printer" + "3" "KlipperScreen - a touchscreen GUI that interfaces with Klipper via Moonraker" + "4" "Duet Web Control - a fully-responsive HTML5-based web interface for RepRapFirmware" + "5" "OctoPrint - a snappy web interface for controlling consumer 3D printers." + ) + local menu_str="Select an interface to install, you can install multiple interfaces." + + while true; do + local menu + menu=$(whiptail --title "Install Interface" --cancel-button "Back" --notags --menu "$menu_str\n\nPerform Action:" \ + "$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) do_action "install_webui mainsail";; + 2) do_action "install_webui fluidd";; + 3) do_action "install_klipperscreen";; + 4) do_action "dwc_setup_dialog";; + 5) do_action "octoprint_setup_dialog";; + esac + else + # Unexpected event, no clue what happened + exit 1 + fi + done +} diff --git a/scripts/ui/install_menu.sh b/scripts/ui/install_menu.sh index 5c8fc13..6733b72 100755 --- a/scripts/ui/install_menu.sh +++ b/scripts/ui/install_menu.sh @@ -1,55 +1,31 @@ -install_ui(){ - top_border - echo -e "| ${green}~~~~~~~~~~~ [ Installation Menu ] ~~~~~~~~~~~${default} | " - hr - echo -e "| You need this menu usually only for installing | " - echo -e "| all necessary dependencies for the various | " - echo -e "| functions on a completely fresh system. | " - hr - echo -e "| Firmware: | Touchscreen GUI: | " - echo -e "| 1) [Klipper] | 5) [KlipperScreen] | " - echo -e "| | | " - echo -e "| Klipper API: | Other: | " - echo -e "| 2) [Moonraker] | 6) [Duet Web Control] | " - echo -e "| | 7) [OctoPrint] | " - echo -e "| Klipper Webinterface: | 8) [PrettyGCode] | " - echo -e "| 3) [Mainsail] | 9) [Telegram Bot] | " - echo -e "| 4) [Fluidd] | | " - echo -e "| | Webcam: | " - echo -e "| | 10) [MJPG-Streamer] | " - back_footer -} +#!/bin/bash install_menu(){ - do_action "" "install_ui" + local menu_options=( + "1" "Klipper" + "2" "Klipper API(Moonraker)" + "3" "Interfaces" + "4" "Other" + ) + local menu_str="You need this menu usually only for installing all necessary dependencies for the various functions on a completely fresh system." + while true; do - read -p "${cyan}Perform action:${default} " action; echo - case "$action" in - 1) - do_action "klipper_setup_dialog" "install_ui";; - 2) - do_action "moonraker_setup_dialog" "install_ui";; - 3) - do_action "install_webui mainsail" "install_ui";; - 4) - do_action "install_webui fluidd" "install_ui";; - 5) - do_action "install_klipperscreen" "install_ui";; - 6) - do_action "dwc_setup_dialog" "install_ui";; - 7) - do_action "octoprint_setup_dialog" "install_ui";; - 8) - do_action "install_pgc_for_klipper" "install_ui";; - 9) - do_action "install_MoonrakerTelegramBot" "install_ui";; - 10) - do_action "install_mjpg-streamer" "install_ui";; - B|b) - clear; main_menu; break;; - *) - deny_action "install_ui";; - esac + local menu + menu=$(whiptail --title "Install" --cancel-button "Back" --notags --menu "$menu_str\n\nPerform Action:" \ + "$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) do_action "klipper_setup_dialog";; + 2) do_action "moonraker_setup_dialog";; + 3) install_interface_menu;; + 4) install_other_menu;; + esac + else + # Unexpected event, no clue what happened + exit 1 + fi done - install_menu } diff --git a/scripts/ui/install_other_menu.sh b/scripts/ui/install_other_menu.sh new file mode 100755 index 0000000..da5bc52 --- /dev/null +++ b/scripts/ui/install_other_menu.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# +# Brief description of your script + +install_other_menu(){ + + local menu_options=( + #TODO WIP + "1" "PrettyGCode - " + "2" "Klipper Telegram Bot - " + "3" "Webcam MJPG-Streamer - Use MJPG-Streamer with webcam" + ) + local menu_str="Select an option to install." + + while true; do + local menu + menu=$(whiptail --title "Install Other" --cancel-button "Back" --notags --menu "$menu_str\n\nPerform Action:" \ + "$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) do_action "install_pgc_for_klipper";; + 2) do_action "install_MoonrakerTelegramBot";; + 3) do_action "install_mjpg-streamer";; + esac + else + # Unexpected event, no clue what happened + exit 1 + fi + done +}