refactor: visual tweaks
Signed-off-by: Dominik Willner th33xitus@gmail.com
This commit is contained in:
@@ -21,6 +21,7 @@ function set_globals(){
|
|||||||
#=================== KIAUH ====================#
|
#=================== KIAUH ====================#
|
||||||
green=$(echo -en "\e[92m")
|
green=$(echo -en "\e[92m")
|
||||||
yellow=$(echo -en "\e[93m")
|
yellow=$(echo -en "\e[93m")
|
||||||
|
magenta=$(echo -en "\e[95m")
|
||||||
red=$(echo -en "\e[91m")
|
red=$(echo -en "\e[91m")
|
||||||
cyan=$(echo -en "\e[96m")
|
cyan=$(echo -en "\e[96m")
|
||||||
white=$(echo -en "\e[39m")
|
white=$(echo -en "\e[39m")
|
||||||
|
|||||||
@@ -55,11 +55,10 @@ function klipper_setup_dialog(){
|
|||||||
top_border
|
top_border
|
||||||
echo -e "| Please select the number of Klipper instances to set |"
|
echo -e "| Please select the number of Klipper instances to set |"
|
||||||
echo -e "| up. The number of Klipper instances will determine |"
|
echo -e "| up. The number of Klipper instances will determine |"
|
||||||
echo -e "| the amount of printers you can run from this machine. |"
|
echo -e "| the amount of printers you can run from this host. |"
|
||||||
blank_line
|
blank_line
|
||||||
echo -e "| ${yellow}WARNING: There is no limit on the number of instances${white} |"
|
echo -e "| ${yellow}WARNING:${white} |"
|
||||||
echo -e "| ${yellow}you can set up with this script. Setting up too many${white} |"
|
echo -e "| ${yellow}Setting up too many instances may crash your system.${white} |"
|
||||||
echo -e "| ${yellow}Klipper instances can potentially crash your system.${white} |"
|
|
||||||
bottom_border
|
bottom_border
|
||||||
|
|
||||||
local count
|
local count
|
||||||
@@ -74,7 +73,8 @@ function klipper_setup_dialog(){
|
|||||||
case "${yn}" in
|
case "${yn}" in
|
||||||
Y|y|Yes|yes|"")
|
Y|y|Yes|yes|"")
|
||||||
select_msg "Yes"
|
select_msg "Yes"
|
||||||
status_msg "Installing ${count} Klipper instance(s) ... \n"
|
((count == 1)) && status_msg "Installing single Klipper instance ..."
|
||||||
|
((count > 1)) && status_msg "Installing ${count} Klipper instances ..."
|
||||||
klipper_setup "${count}" "${python_version}"
|
klipper_setup "${count}" "${python_version}"
|
||||||
break;;
|
break;;
|
||||||
N|n|No|no)
|
N|n|No|no)
|
||||||
@@ -82,7 +82,7 @@ function klipper_setup_dialog(){
|
|||||||
abort_msg "Exiting Klipper setup ...\n"
|
abort_msg "Exiting Klipper setup ...\n"
|
||||||
break;;
|
break;;
|
||||||
*)
|
*)
|
||||||
error_msg "Invalid Input!\n";;
|
error_msg "Invalid Input!";;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ function advanced_ui(){
|
|||||||
function advanced_menu(){
|
function advanced_menu(){
|
||||||
do_action "" "advanced_ui"
|
do_action "" "advanced_ui"
|
||||||
while true; do
|
while true; do
|
||||||
read -p "${cyan}Perform action:${white} " action; echo
|
read -p "${cyan}####### Perform action:${white} " action
|
||||||
case "${action}" in
|
case "${action}" in
|
||||||
1)
|
1)
|
||||||
do_action "load_klipper_state" "advanced_ui";;
|
do_action "load_klipper_state" "advanced_ui";;
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ function backup_ui(){
|
|||||||
function backup_menu(){
|
function backup_menu(){
|
||||||
do_action "" "backup_ui"
|
do_action "" "backup_ui"
|
||||||
while true; do
|
while true; do
|
||||||
read -p "${cyan}Perform action:${white} " action; echo
|
read -p "${cyan}####### Perform action:${white} " action
|
||||||
case "${action}" in
|
case "${action}" in
|
||||||
0)
|
0)
|
||||||
do_action "backup_klipper_config_dir" "backup_ui";;
|
do_action "backup_klipper_config_dir" "backup_ui";;
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ function install_menu(){
|
|||||||
install_ui
|
install_ui
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
read -p "${cyan}Perform action:${white} " action; echo
|
read -p "${cyan}####### Perform action:${white} " action
|
||||||
case "${action}" in
|
case "${action}" in
|
||||||
1)clear && print_header
|
1)clear && print_header
|
||||||
select_klipper_python_version
|
select_klipper_python_version
|
||||||
@@ -79,7 +79,7 @@ function select_klipper_python_version(){
|
|||||||
echo -e "| 2) [Python 3.x] ${yellow}(experimental)${white} | "
|
echo -e "| 2) [Python 3.x] ${yellow}(experimental)${white} | "
|
||||||
back_footer
|
back_footer
|
||||||
while true; do
|
while true; do
|
||||||
read -p "${cyan}###### Select Python version:${white} " action; echo
|
read -p "${cyan}###### Select Python version:${white} " action
|
||||||
case "${action}" in
|
case "${action}" in
|
||||||
1)
|
1)
|
||||||
select_msg "Python 2.7"
|
select_msg "Python 2.7"
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ function main_menu(){
|
|||||||
kiauh_update_dialog
|
kiauh_update_dialog
|
||||||
main_ui
|
main_ui
|
||||||
while true; do
|
while true; do
|
||||||
read -p "${cyan}Perform action:${white} " action; echo
|
read -p "${cyan}####### Perform action:${white} " action
|
||||||
case "${action}" in
|
case "${action}" in
|
||||||
"start klipper") do_action_service "start" "klipper"; main_ui;;
|
"start klipper") do_action_service "start" "klipper"; main_ui;;
|
||||||
"stop klipper") do_action_service "stop" "klipper"; main_ui;;
|
"stop klipper") do_action_service "stop" "klipper"; main_ui;;
|
||||||
|
|||||||
@@ -15,8 +15,7 @@ function remove_ui(){
|
|||||||
top_border
|
top_border
|
||||||
echo -e "| ${red}~~~~~~~~~~~~~~ [ Remove Menu ] ~~~~~~~~~~~~~~${white} | "
|
echo -e "| ${red}~~~~~~~~~~~~~~ [ Remove Menu ] ~~~~~~~~~~~~~~${white} | "
|
||||||
hr
|
hr
|
||||||
echo -e "| ${yellow}INFO:${white} | "
|
echo -e "| ${yellow}INFO: Configurations and/or any backups will be kept!${white} | "
|
||||||
echo -e "| Printer configs or backups always remain untouched! | "
|
|
||||||
hr
|
hr
|
||||||
echo -e "| Firmware: | Touchscreen GUI: | "
|
echo -e "| Firmware: | Touchscreen GUI: | "
|
||||||
echo -e "| 1) [Klipper] | 5) [KlipperScreen] | "
|
echo -e "| 1) [Klipper] | 5) [KlipperScreen] | "
|
||||||
@@ -33,7 +32,7 @@ function remove_ui(){
|
|||||||
function remove_menu(){
|
function remove_menu(){
|
||||||
do_action "" "remove_ui"
|
do_action "" "remove_ui"
|
||||||
while true; do
|
while true; do
|
||||||
read -p "${cyan}Perform action:${white} " action; echo
|
read -p "${cyan}####### Perform action:${white} " action
|
||||||
case "${action}" in
|
case "${action}" in
|
||||||
1)
|
1)
|
||||||
do_action "remove_klipper" "remove_ui";;
|
do_action "remove_klipper" "remove_ui";;
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ function settings_menu(){
|
|||||||
clear && print_header
|
clear && print_header
|
||||||
settings_ui
|
settings_ui
|
||||||
while true; do
|
while true; do
|
||||||
read -p "${cyan}Perform action:${white} " action; echo
|
read -p "${cyan}####### Perform action:${white} " action
|
||||||
case "${action}" in
|
case "${action}" in
|
||||||
1)
|
1)
|
||||||
change_klipper_cfg_folder && settings_ui;;
|
change_klipper_cfg_folder && settings_ui;;
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ function update_menu(){
|
|||||||
read_bb4u_stat
|
read_bb4u_stat
|
||||||
do_action "" "update_ui"
|
do_action "" "update_ui"
|
||||||
while true; do
|
while true; do
|
||||||
read -p "${cyan}Perform action:${white} " action; echo
|
read -p "${cyan}####### Perform action:${white} " action
|
||||||
case "${action}" in
|
case "${action}" in
|
||||||
0)
|
0)
|
||||||
do_action "toggle_backups" "update_ui";;
|
do_action "toggle_backups" "update_ui";;
|
||||||
|
|||||||
@@ -32,13 +32,13 @@ function check_euid(){
|
|||||||
#================================================#
|
#================================================#
|
||||||
|
|
||||||
function select_msg() {
|
function select_msg() {
|
||||||
echo -e "${white}>>>>>> ${1}"
|
echo -e "${white} [➔] ${1}"
|
||||||
}
|
}
|
||||||
function status_msg(){
|
function status_msg(){
|
||||||
echo -e "${yellow}###### ${1}${white}"
|
echo -e "\n${magenta}###### ${1}${white}"
|
||||||
}
|
}
|
||||||
function ok_msg(){
|
function ok_msg(){
|
||||||
echo -e "${green}>>>>>> ${1}${white}"
|
echo -e "${green}[✓ OK] ${1}${white}"
|
||||||
}
|
}
|
||||||
function warn_msg(){
|
function warn_msg(){
|
||||||
echo -e "${yellow}>>>>>> ${1}${white}"
|
echo -e "${yellow}>>>>>> ${1}${white}"
|
||||||
@@ -56,18 +56,18 @@ function title_msg(){
|
|||||||
function print_error(){
|
function print_error(){
|
||||||
[ -z "${1}" ] && return
|
[ -z "${1}" ] && return
|
||||||
echo -e "${red}"
|
echo -e "${red}"
|
||||||
echo -e "#########################################################"
|
echo -e "#=======================================================#"
|
||||||
echo -e " ${1} "
|
echo -e " ${1} "
|
||||||
echo -e "#########################################################"
|
echo -e "#=======================================================#"
|
||||||
echo -e "${white}"
|
echo -e "${white}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function print_confirm(){
|
function print_confirm(){
|
||||||
[ -z "${1}" ] && return
|
[ -z "${1}" ] && return
|
||||||
echo -e "${green}"
|
echo -e "${green}"
|
||||||
echo -e "#########################################################"
|
echo -e "#=======================================================#"
|
||||||
echo -e " ${1} "
|
echo -e " ${1} "
|
||||||
echo -e "#########################################################"
|
echo -e "#=======================================================#"
|
||||||
echo -e "${white}"
|
echo -e "${white}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -371,30 +371,32 @@ function python3_check(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function dependency_check(){
|
function dependency_check(){
|
||||||
local dep=( "${@}" ) # dep: array
|
local dep=( "${@}" )
|
||||||
|
local packages
|
||||||
status_msg "Checking for the following dependencies:"
|
status_msg "Checking for the following dependencies:"
|
||||||
#check if package is installed, if not write name into array
|
#check if package is installed, if not write its name into array
|
||||||
for pkg in "${dep[@]}"
|
for pkg in "${dep[@]}"; do
|
||||||
do
|
|
||||||
echo -e "${cyan}● ${pkg} ${white}"
|
echo -e "${cyan}● ${pkg} ${white}"
|
||||||
if [[ ! $(dpkg-query -f'${Status}' --show "${pkg}" 2>/dev/null) = *\ installed ]]; then
|
if [[ ! $(dpkg-query -f'${Status}' --show "${pkg}" 2>/dev/null) = *\ installed ]]; then
|
||||||
inst+=("${pkg}")
|
packages+=("${pkg}")
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
#if array is not empty, install packages from array elements
|
#if array is not empty, install packages from array
|
||||||
if [ "${#inst[@]}" -ne 0 ]; then
|
if (( ${#packages[@]} > 0 )); then
|
||||||
status_msg "Installing the following dependencies:"
|
status_msg "Installing the following dependencies:"
|
||||||
for element in "${inst[@]}"
|
for package in "${packages[@]}"; do
|
||||||
do
|
echo -e "${cyan}● ${package} ${white}"
|
||||||
echo -e "${cyan}● ${element} ${white}"
|
|
||||||
done
|
done
|
||||||
echo
|
echo
|
||||||
sudo apt-get update --allow-releaseinfo-change && sudo apt-get install "${inst[@]}" -y
|
if sudo apt-get update --allow-releaseinfo-change && sudo apt-get install "${packages[@]}" -y; then
|
||||||
ok_msg "Dependencies installed!"
|
ok_msg "Dependencies installed!"
|
||||||
#clearing the array
|
|
||||||
unset inst
|
|
||||||
else
|
else
|
||||||
ok_msg "Dependencies already met! Continue..."
|
error_msg "Installing dependencies failed!"
|
||||||
|
return 1 # exit kiauh
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
ok_msg "Dependencies already met!"
|
||||||
|
return
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user