From c297339e9ef21e2058e796682b0ee5c4a34558d1 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 18 Nov 2025 22:42:55 +0000 Subject: [PATCH] refactor: improve maintainability of omarchy-setup.sh Dynamically generate the "Install All" module list instead of hardcoding it. This makes the script easier to extend and less prone to error when adding or removing modules. Also, improve the user-facing text for the "Install All" option to be clearer and more accurate. Finally, remove unused code to clean up the script. --- omarchy-setup.sh | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/omarchy-setup.sh b/omarchy-setup.sh index 762d26e..725326f 100755 --- a/omarchy-setup.sh +++ b/omarchy-setup.sh @@ -37,10 +37,6 @@ chmod +x "${MODULES_DIR}"/*.sh 2>/dev/null || true SPINNER_ACTIVE=0 SPINNER_MESSAGE= -spinner_clear_line() { - : -} - pause_spinner() { if (( SPINNER_ACTIVE )); then SPINNER_ACTIVE=0 @@ -141,8 +137,23 @@ MODULES=( ["H"]="hyprland-config;run_module_main;🎨 Instalar Configuración de Hyprland;bg" ) +# Módulos a excluir de la opción "Instalar Todo" +EXCLUDED_FROM_ALL=("R") + +# Generar dinámicamente la lista de módulos para "Instalar Todo" +get_install_all_choices() { + local choices=() + for key in $(printf '%s\n' "${!MODULES[@]}" | sort -V); do + # Verificar si la clave no está en el array de exclusión + if ! [[ " ${EXCLUDED_FROM_ALL[*]} " =~ " ${key} " ]]; then + choices+=("$key") + fi + done + echo "${choices[@]}" +} + # Módulos a incluir en la opción "Instalar Todo" -INSTALL_ALL_CHOICES=("1" "2" "K" "3" "4" "5" "6" "7" "F" "H") +INSTALL_ALL_CHOICES=($(get_install_all_choices)) # Función para mostrar el menú show_menu() { @@ -160,7 +171,8 @@ show_menu() { echo -e " ${GREEN}${key})${NC} ${description}" done | sort -V - echo -e " ${GREEN}A)${NC} ✅ Instalar Todo (1, 2, 3, 4, 5, 6, 7, F, H)" + local install_all_keys=$(IFS=,; echo "${INSTALL_ALL_CHOICES[*]}") + echo -e " ${GREEN}A)${NC} ✅ Instalar Todo (${install_all_keys//,/, }) (excluye DaVinci)" echo -e " ${GREEN}0)${NC} 🚪 Salir" echo "" echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" @@ -265,9 +277,6 @@ install_all() { local failed=() for choice in "${INSTALL_ALL_CHOICES[@]}"; do - if [[ "$choice" == "R" ]]; then - continue - fi IFS=';' read -r module_file _ description type <<< "${MODULES[$choice]}" if ! ensure_sudo_session; then @@ -337,7 +346,6 @@ main() { export -f stop_spinner export -f pause_spinner export -f resume_spinner - export -f spinner_clear_line export -f ensure_sudo_session while true; do @@ -385,8 +393,9 @@ main() { read -p "Presiona Enter para continuar..." elif [[ "$choice" == "A" ]]; then - log_warning "La opción 'Instalar Todo' ejecutará los módulos: 1, 2, K, 3, 4, 5, 6, 7, F y H." - log_info "DaVinci Resolve (opción R) no se ejecutará en este lote; instálalo aparte cuando ya tengas el ZIP." + local modules_to_install=$(IFS=,; echo "${INSTALL_ALL_CHOICES[*]}") + log_warning "La opción 'Instalar Todo' ejecutará los módulos: ${modules_to_install//,/, }." + log_info "Los módulos excluidos (como DaVinci Resolve) deben instalarse por separado." echo -ne "${BOLD}¿Confirmas que deseas instalar todas las opciones ahora? [s/N]: ${NC}" read -r confirm if [[ "${confirm}" =~ ^[SsYy]$ ]]; then