script: whiptail remove menu

This commit is contained in:
Yifei Ding
2021-11-13 01:17:44 -08:00
parent d7ab5dc017
commit a5ae3fb891
3 changed files with 102 additions and 31 deletions

View File

@@ -1,3 +1,4 @@
#!/bin/bash
remove_ui(){
top_border
echo -e "| ${red}~~~~~~~~~~~~~~ [ Remove Menu ] ~~~~~~~~~~~~~~${default} | "
@@ -22,37 +23,37 @@ remove_ui(){
}
remove_menu(){
do_action "" "remove_ui"
#TODO Currently it's a "dumb" remove page, looking for a "smart" one
local menu_options=(
"1" "Klipper"
"2" "Klipper API(Moonraker)"
"3" "Interfaces"
"4" "Other"
)
local menu_str="Directories which remain untouched:
Your printer configuration directory
~/kiauh-backups
You need remove them manually if you wish so."
while true; do
read -p "${cyan}Perform action:${default} " action; echo
case "$action" in
1)
do_action "remove_klipper" "remove_ui";;
2)
do_action "remove_moonraker" "remove_ui";;
3)
do_action "remove_mainsail" "remove_ui";;
4)
do_action "remove_fluidd" "remove_ui";;
5)
do_action "remove_klipperscreen" "remove_ui";;
6)
do_action "remove_dwc2" "remove_ui";;
7)
do_action "remove_octoprint" "remove_ui";;
8)
do_action "remove_prettygcode" "remove_ui";;
9)
do_action "remove_MoonrakerTelegramBot" "remove_ui";;
10)
do_action "remove_mjpg-streamer" "remove_ui";;
11)
do_action "remove_nginx" "remove_ui";;
B|b)
clear; main_menu; break;;
*)
deny_action "remove_ui";;
esac
local menu
menu=$(whiptail --title "Remove Menu" --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 "remove_klipper";;
2) do_action "remove_moonraker";;
3) remove_interface_menu;;
4) remove_other_menu;;
esac
else
# Unexpected event, no clue what happened
exit 1
fi
done
remove_menu
}