fix: install mainsail theme to correct folder (fixes #222)

Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
th33xitus
2022-07-20 22:41:42 +02:00
parent 491d6f40bb
commit ae011963da

View File

@@ -377,16 +377,34 @@ function ms_theme_installer_menu() {
} }
function ms_theme_install() { function ms_theme_install() {
local theme_url=${1} theme_name theme_note read_kiauh_ini "${FUNCNAME[0]}"
theme_name=${2} theme_note=${3}
local config_folders target_folders=() local theme_url
config_folders=$(find "${KLIPPER_CONFIG}" -mindepth 1 -maxdepth 1 -type d | sort) local theme_name
local theme_note
theme_url=${1}
theme_name=${2}
theme_note=${3}
### build target folder array local folder_arr
for folder in ${config_folders}; do local folder_names="${multi_instance_names}"
target_folders+=("${folder}") local target_folders=()
done
IFS=',' read -r -a folder_arr <<< "${folder_names}"
### build theme target folder array
if (( ${#folder_arr[@]} > 1 )); then
for folder in "${folder_arr[@]}"; do
### instance names/identifier of only numbers need to be prefixed with 'printer_'
if [[ ${folder} =~ ^[0-9]+$ ]]; then
target_folders+=("${KLIPPER_CONFIG}/printer_${folder}")
else
target_folders+=("${KLIPPER_CONFIG}/${folder}")
fi
done
else
target_folders+=("${KLIPPER_CONFIG}")
fi
if (( ${#target_folders[@]} > 1 )); then if (( ${#target_folders[@]} > 1 )); then
top_border top_border
@@ -430,7 +448,10 @@ function ms_theme_delete() {
target_folders+=("${folder}") target_folders+=("${folder}")
done done
if (( ${#target_folders[@]} > 0 )); then if (( ${#target_folders[@]} == 0 )); then
status_msg "No Themes installed!\n"
return
elif (( ${#target_folders[@]} > 1 )); then
top_border top_border
echo -e "| Please select the printer you want to remove the |" echo -e "| Please select the printer you want to remove the |"
echo -e "| theme installation from. |" echo -e "| theme installation from. |"
@@ -447,9 +468,6 @@ function ms_theme_delete() {
[[ ${target} =~ ${re} && ${target} -lt ${#target_folders[@]} ]] && break [[ ${target} =~ ${re} && ${target} -lt ${#target_folders[@]} ]] && break
error_msg "Invalid command!" error_msg "Invalid command!"
done done
else
status_msg "No Themes installed!\n"
return
fi fi
status_msg "Removing ${target_folders[${target}]} ..." status_msg "Removing ${target_folders[${target}]} ..."