diff --git a/lib/utils.sh b/lib/utils.sh index feceab0..d0804d7 100755 --- a/lib/utils.sh +++ b/lib/utils.sh @@ -255,36 +255,56 @@ prompt_ollama_models_path() { tty_out="/dev/stderr" fi - # If whiptail is available and running on an active terminal, use whiptail dialog + # If whiptail is available and running on an active terminal, first ask + # whether the configured default path should be used, and only show + # the free-text path dialog (pre-filled with that default) if not. if command_exists whiptail && has_tty; then - local tui_tmp - tui_tmp="$(mktemp)" - if run_whiptail --output-fd 3 --title "Ollama KI-Modelle Speicherort" \ - --inputbox "Bitte gib den Speicherort für die Ollama KI-Modelle an:" \ - 10 70 "$default_path" \ - 3> "$tui_tmp"; then - local tui_input - tui_input="$(sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' < "$tui_tmp")" - if [[ -n "$tui_input" ]]; then - chosen="$tui_input" + if run_whiptail --title "Ollama KI-Modelle Speicherort" \ + --yes-button "Standard verwenden" --no-button "Eigenen Pfad angeben" \ + --yesno "Standard-Speicherort für Ollama-Modelle:\n\n$default_path\n\nMöchtest du diesen Speicherort verwenden?" \ + 12 70; then + chosen="$default_path" + else + local tui_tmp + tui_tmp="$(mktemp)" + if run_whiptail --output-fd 3 --title "Ollama KI-Modelle Speicherort" \ + --inputbox "Bitte gib den Speicherort für die Ollama KI-Modelle an:" \ + 10 70 "$default_path" \ + 3> "$tui_tmp"; then + local tui_input + tui_input="$(sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' < "$tui_tmp")" + if [[ -n "$tui_input" ]]; then + chosen="$tui_input" + else + chosen="$default_path" + fi else + # Dialog cancelled - fall back to the configured default + # instead of dropping into the CLI prompt below too. chosen="$default_path" fi + rm -f "$tui_tmp" fi - rm -f "$tui_tmp" fi # CLI fallback if whiptail was not used or failed if [[ -z "$chosen" ]]; then printf "\n%bOllama KI-Modelle Speicherort:%b\n" "${CLR_CYAN}" "${CLR_RESET}" > "$tty_out" printf "Standard-Pfad: %b%s%b\n" "${CLR_BOLD}" "$default_path" "${CLR_RESET}" > "$tty_out" - local input_path="" - read -r -p "Speicherort für Ollama-Modelle eingeben [$default_path]: " input_path < "$tty_in" > "$tty_out" 2>&1 || true - input_path="$(echo "$input_path" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" - if [[ -n "$input_path" ]]; then - chosen="$input_path" - else + local use_default="" + read -r -p "Standard-Speicherort verwenden? [J/n]: " use_default < "$tty_in" > "$tty_out" 2>&1 || use_default="j" + use_default="$(echo "$use_default" | xargs)" + if [[ -z "$use_default" || "$use_default" =~ ^[JjYy] ]]; then chosen="$default_path" + else + local input_path="" + read -r -p "Speicherort für Ollama-Modelle eingeben [$default_path]: " input_path < "$tty_in" > "$tty_out" 2>&1 || true + input_path="$(echo "$input_path" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" + if [[ -n "$input_path" ]]; then + chosen="$input_path" + else + chosen="$default_path" + fi fi fi else