refactor: visual tweaks

Signed-off-by: Dominik Willner th33xitus@gmail.com
This commit is contained in:
th33xitus
2022-04-21 19:44:25 +02:00
parent 551b040021
commit a0ca25a99a
10 changed files with 40 additions and 38 deletions

View File

@@ -21,6 +21,7 @@ function set_globals(){
#=================== KIAUH ====================#
green=$(echo -en "\e[92m")
yellow=$(echo -en "\e[93m")
magenta=$(echo -en "\e[95m")
red=$(echo -en "\e[91m")
cyan=$(echo -en "\e[96m")
white=$(echo -en "\e[39m")

View File

@@ -55,11 +55,10 @@ function klipper_setup_dialog(){
top_border
echo -e "| Please select the number of Klipper instances to set |"
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
echo -e "| ${yellow}WARNING: There is no limit on the number of instances${white} |"
echo -e "| ${yellow}you can set up with this script. Setting up too many${white} |"
echo -e "| ${yellow}Klipper instances can potentially crash your system.${white} |"
echo -e "| ${yellow}WARNING:${white} |"
echo -e "| ${yellow}Setting up too many instances may crash your system.${white} |"
bottom_border
local count
@@ -74,7 +73,8 @@ function klipper_setup_dialog(){
case "${yn}" in
Y|y|Yes|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}"
break;;
N|n|No|no)
@@ -82,7 +82,7 @@ function klipper_setup_dialog(){
abort_msg "Exiting Klipper setup ...\n"
break;;
*)
error_msg "Invalid Input!\n";;
error_msg "Invalid Input!";;
esac
done
fi

View File

@@ -29,7 +29,7 @@ function advanced_ui(){
function advanced_menu(){
do_action "" "advanced_ui"
while true; do
read -p "${cyan}Perform action:${white} " action; echo
read -p "${cyan}####### Perform action:${white} " action
case "${action}" in
1)
do_action "load_klipper_state" "advanced_ui";;

View File

@@ -33,7 +33,7 @@ function backup_ui(){
function backup_menu(){
do_action "" "backup_ui"
while true; do
read -p "${cyan}Perform action:${white} " action; echo
read -p "${cyan}####### Perform action:${white} " action
case "${action}" in
0)
do_action "backup_klipper_config_dir" "backup_ui";;

View File

@@ -37,7 +37,7 @@ function install_menu(){
install_ui
while true; do
read -p "${cyan}Perform action:${white} " action; echo
read -p "${cyan}####### Perform action:${white} " action
case "${action}" in
1)clear && print_header
select_klipper_python_version
@@ -79,7 +79,7 @@ function select_klipper_python_version(){
echo -e "| 2) [Python 3.x] ${yellow}(experimental)${white} | "
back_footer
while true; do
read -p "${cyan}###### Select Python version:${white} " action; echo
read -p "${cyan}###### Select Python version:${white} " action
case "${action}" in
1)
select_msg "Python 2.7"

View File

@@ -66,7 +66,7 @@ function main_menu(){
kiauh_update_dialog
main_ui
while true; do
read -p "${cyan}Perform action:${white} " action; echo
read -p "${cyan}####### Perform action:${white} " action
case "${action}" in
"start klipper") do_action_service "start" "klipper"; main_ui;;
"stop klipper") do_action_service "stop" "klipper"; main_ui;;

View File

@@ -15,8 +15,7 @@ function remove_ui(){
top_border
echo -e "| ${red}~~~~~~~~~~~~~~ [ Remove Menu ] ~~~~~~~~~~~~~~${white} | "
hr
echo -e "| ${yellow}INFO:${white} | "
echo -e "| Printer configs or backups always remain untouched! | "
echo -e "| ${yellow}INFO: Configurations and/or any backups will be kept!${white} | "
hr
echo -e "| Firmware: | Touchscreen GUI: | "
echo -e "| 1) [Klipper] | 5) [KlipperScreen] | "
@@ -33,7 +32,7 @@ function remove_ui(){
function remove_menu(){
do_action "" "remove_ui"
while true; do
read -p "${cyan}Perform action:${white} " action; echo
read -p "${cyan}####### Perform action:${white} " action
case "${action}" in
1)
do_action "remove_klipper" "remove_ui";;

View File

@@ -121,7 +121,7 @@ function settings_menu(){
clear && print_header
settings_ui
while true; do
read -p "${cyan}Perform action:${white} " action; echo
read -p "${cyan}####### Perform action:${white} " action
case "${action}" in
1)
change_klipper_cfg_folder && settings_ui;;

View File

@@ -43,7 +43,7 @@ function update_menu(){
read_bb4u_stat
do_action "" "update_ui"
while true; do
read -p "${cyan}Perform action:${white} " action; echo
read -p "${cyan}####### Perform action:${white} " action
case "${action}" in
0)
do_action "toggle_backups" "update_ui";;

View File

@@ -32,13 +32,13 @@ function check_euid(){
#================================================#
function select_msg() {
echo -e "${white}>>>>>> ${1}"
echo -e "${white} [➔] ${1}"
}
function status_msg(){
echo -e "${yellow}###### ${1}${white}"
echo -e "\n${magenta}###### ${1}${white}"
}
function ok_msg(){
echo -e "${green}>>>>>> ${1}${white}"
echo -e "${green}[✓ OK] ${1}${white}"
}
function warn_msg(){
echo -e "${yellow}>>>>>> ${1}${white}"
@@ -56,18 +56,18 @@ function title_msg(){
function print_error(){
[ -z "${1}" ] && return
echo -e "${red}"
echo -e "#########################################################"
echo -e "#=======================================================#"
echo -e " ${1} "
echo -e "#########################################################"
echo -e "#=======================================================#"
echo -e "${white}"
}
function print_confirm(){
[ -z "${1}" ] && return
echo -e "${green}"
echo -e "#########################################################"
echo -e "#=======================================================#"
echo -e " ${1} "
echo -e "#########################################################"
echo -e "#=======================================================#"
echo -e "${white}"
}
@@ -371,30 +371,32 @@ function python3_check(){
}
function dependency_check(){
local dep=( "${@}" ) # dep: array
local dep=( "${@}" )
local packages
status_msg "Checking for the following dependencies:"
#check if package is installed, if not write name into array
for pkg in "${dep[@]}"
do
#check if package is installed, if not write its name into array
for pkg in "${dep[@]}"; do
echo -e "${cyan}${pkg} ${white}"
if [[ ! $(dpkg-query -f'${Status}' --show "${pkg}" 2>/dev/null) = *\ installed ]]; then
inst+=("${pkg}")
packages+=("${pkg}")
fi
done
#if array is not empty, install packages from array elements
if [ "${#inst[@]}" -ne 0 ]; then
#if array is not empty, install packages from array
if (( ${#packages[@]} > 0 )); then
status_msg "Installing the following dependencies:"
for element in "${inst[@]}"
do
echo -e "${cyan}${element} ${white}"
for package in "${packages[@]}"; do
echo -e "${cyan}${package} ${white}"
done
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!"
#clearing the array
unset inst
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
}