fullscreen TUI from start: pretty box drawings, module selection with y/N, progress bar during execution
This commit is contained in:
95
install.sh
95
install.sh
@@ -101,27 +101,18 @@ detect_environment() {
|
||||
tui_detect
|
||||
|
||||
if ((!OMERON_HAS_GUM)) && have pacman; then
|
||||
printf '\033[1;36m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\033[0m\n'
|
||||
printf '\033[1;36m O M E R O N — Modular System Setup Framework\033[0m\n'
|
||||
printf '\033[1;36m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\033[0m\n'
|
||||
printf '\n'
|
||||
printf ' \033[1;33mgum is not installed.\033[0m Installing it enables the full TUI experience.\n'
|
||||
printf '\n'
|
||||
|
||||
if tui_install_gum; then
|
||||
printf ' \033[1;32m✓ gum installed!\033[0m\n'
|
||||
tui_fs_show_msg "Installing gum for interactive TUI..."
|
||||
tui_install_gum 2>/dev/null || true
|
||||
tui_detect
|
||||
if ((OMERON_HAS_GUM)); then
|
||||
tui_fs_show_ok "gum installed"
|
||||
else
|
||||
if ((OMERON_HAS_WHIPTAIL)); then
|
||||
printf ' \033[1;33musing whiptail as fallback\033[0m\n'
|
||||
else
|
||||
printf ' \033[1;33musing basic text mode (install gum for UI: pacman -S gum)\033[0m\n'
|
||||
fi
|
||||
tui_fs_show_msg "using terminal prompts"
|
||||
fi
|
||||
printf '\n'
|
||||
fi
|
||||
|
||||
if ((!OMERON_FRESH_INSTALL)) && ((${#RUN_MODULES[@]} == 0)); then
|
||||
log_info "Checking for fresh install..."
|
||||
tui_fs_show_msg "Checking for fresh install..."
|
||||
if is_fresh_install; then
|
||||
OMERON_FRESH_INSTALL=1
|
||||
export OMERON_FRESH_INSTALL
|
||||
@@ -131,9 +122,12 @@ detect_environment() {
|
||||
if ((OMERON_FRESH_INSTALL)); then
|
||||
if ((!OMERON_HAS_GUM)) && have pacman; then
|
||||
tui_install_gum 2>/dev/null || true
|
||||
tui_detect
|
||||
fi
|
||||
if ! have paru && ! have yay; then
|
||||
tui_fs_show_msg "Installing AUR helper..."
|
||||
install_aur_helper
|
||||
tui_fs_show_ok "AUR helper ready"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
@@ -181,11 +175,12 @@ collect_all_interactive() {
|
||||
fi
|
||||
|
||||
local module_order=()
|
||||
local idx=1
|
||||
local total=${#modules[@]}
|
||||
|
||||
for mod in "${modules[@]}"; do
|
||||
local module_file="$OMERON_MODULE_DIR/$mod.sh"
|
||||
[[ -f "$module_file" ]] || continue
|
||||
|
||||
source "$module_file" 2>/dev/null || continue
|
||||
|
||||
local description=""
|
||||
@@ -193,32 +188,35 @@ collect_all_interactive() {
|
||||
description="$(module_description)"
|
||||
fi
|
||||
|
||||
local required=0
|
||||
if declare -F "module_required" >/dev/null 2>&1; then
|
||||
if module_required; then
|
||||
module_order+=("$module_file")
|
||||
continue
|
||||
required=1
|
||||
fi
|
||||
fi
|
||||
|
||||
printf ' '
|
||||
if tui_confirm "${description:-$mod}"; then
|
||||
if ((required)); then
|
||||
tui_fs_select_module "$idx" "$total" "$mod" "$description" 1
|
||||
module_order+=("$module_file")
|
||||
((idx++))
|
||||
continue
|
||||
fi
|
||||
|
||||
if tui_fs_select_module "$idx" "$total" "$mod" "$description" 0; then
|
||||
module_order+=("$module_file")
|
||||
fi
|
||||
((idx++))
|
||||
done
|
||||
|
||||
if ! tui_fs_confirm_start "${#module_order[@]}"; then
|
||||
exec 3>&-
|
||||
return 1
|
||||
fi
|
||||
|
||||
printf '%s\n' "${module_order[@]}" >&3
|
||||
exec 3>&-
|
||||
}
|
||||
|
||||
show_banner() {
|
||||
tui_header "O M E R O N — Modular System Setup"
|
||||
printf '\n'
|
||||
if ((OMERON_FRESH_INSTALL)); then
|
||||
tui_info "Fresh install: Hyprland + GPU drivers + all dependencies"
|
||||
printf '\n'
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
OMERON_LOG_FILE="${OMERON_LOG_FILE:-$HOME/.local/share/omeron/install-$(date +%Y%m%d-%H%M%S).log}"
|
||||
export OMERON_LOG_FILE
|
||||
@@ -231,45 +229,42 @@ main() {
|
||||
log_info "Project: $OMERON_ROOT"
|
||||
|
||||
sudo_init
|
||||
trap 'sudo_cleanup' EXIT
|
||||
trap 'sudo_cleanup; tui_fs_exit' EXIT
|
||||
|
||||
tui_fs_init
|
||||
|
||||
detect_environment
|
||||
|
||||
show_banner
|
||||
|
||||
tui_separator
|
||||
printf '\n'
|
||||
if ! tui_confirm "Continue with installation"; then
|
||||
tui_info "Installation cancelled."
|
||||
exit 0
|
||||
fi
|
||||
printf '\n'
|
||||
|
||||
local modules_to_run=()
|
||||
if ((${#RUN_MODULES[@]})); then
|
||||
mapfile -t modules_to_run < <(collect_modules)
|
||||
else
|
||||
mapfile -t modules_to_run < <(collect_all_interactive)
|
||||
local collected
|
||||
collected="$(collect_all_interactive)" || {
|
||||
tui_fs_exit
|
||||
exit 0
|
||||
}
|
||||
mapfile -t modules_to_run <<< "$collected"
|
||||
fi
|
||||
|
||||
if ((${#modules_to_run[@]} == 0)); then
|
||||
tui_warn "No modules selected. Nothing to do."
|
||||
tui_fs_show_msg "No modules selected. Nothing to do."
|
||||
tui_fs_exit
|
||||
exit 0
|
||||
fi
|
||||
|
||||
tui_fs_start_execution
|
||||
|
||||
local total=${#modules_to_run[@]}
|
||||
local idx=1
|
||||
|
||||
tui_fs_init
|
||||
local fs_active=$?
|
||||
|
||||
for module_path in "${modules_to_run[@]}"; do
|
||||
local description=""
|
||||
if source "$module_path" 2>/dev/null && declare -F "module_description" >/dev/null 2>&1; then
|
||||
description="$(module_description)"
|
||||
fi
|
||||
|
||||
((fs_active == 0)) && tui_fs_set_overall "$idx" "$total" "${description:-$(basename "$module_path" .sh)}"
|
||||
tui_fs_set_step "$idx" "$total" "${description:-$(basename "$module_path" .sh)}"
|
||||
printf '\n'
|
||||
log_step "$idx" "$total" "${description:-$(basename "$module_path" .sh)}"
|
||||
|
||||
@@ -278,17 +273,17 @@ main() {
|
||||
if declare -F "module_required" >/dev/null 2>&1; then
|
||||
source "$module_path"
|
||||
if module_required 2>/dev/null; then
|
||||
((fs_active == 0)) && tui_fs_exit
|
||||
tui_fs_exit
|
||||
tui_error "Required module failed. Aborting."
|
||||
exit $rc
|
||||
fi
|
||||
fi
|
||||
tui_warn "Module completed with warnings"
|
||||
tui_fs_show_msg "Module completed with warnings"
|
||||
}
|
||||
((idx++))
|
||||
done
|
||||
|
||||
((fs_active == 0)) && tui_fs_exit
|
||||
tui_fs_exit
|
||||
|
||||
printf '\n'
|
||||
tui_header "O M E R O N — Done"
|
||||
|
||||
Reference in New Issue
Block a user