From 020f55e26c8f19f1908e28e87c02d5eb33891c90 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Mon, 22 Sep 2025 14:30:16 +0200 Subject: [PATCH] Auto-select GPU passthrough when only one option Improves the select_hw_passthrough function to automatically select the available GPU passthrough option if only one is detected, instead of prompting the user. This streamlines the user experience when only a single GPU type is present. --- misc/passthrough.func | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/misc/passthrough.func b/misc/passthrough.func index 0d974ddd..f914e4c2 100644 --- a/misc/passthrough.func +++ b/misc/passthrough.func @@ -23,20 +23,24 @@ select_hw_passthrough() { [[ -d /dev/dri ]] && choices+=("VAAPI" "Intel/AMD GPU via VAAPI" OFF) compgen -G "/dev/nvidia*" >/dev/null && choices+=("NVIDIA" "NVIDIA GPU passthrough" OFF) + # no GPUs found [[ ${#choices[@]} -eq 0 ]] && { msg_info "No GPU devices detected" return } - local HEIGHT WIDTH - HEIGHT=12 - WIDTH=70 local SELECTED - SELECTED=$(whiptail --title "GPU Passthrough" \ - --checklist "Select GPU passthrough for CT $CTID:" $HEIGHT $WIDTH 2 \ - "${choices[@]}" 3>&1 1>&2 2>&3) || return + if [[ ${#choices[@]} -eq 2 ]]; then + # both available → show whiptail + SELECTED=$(whiptail --title "GPU Passthrough" \ + --checklist "Select GPU passthrough for CT $CTID:" 12 70 2 \ + "${choices[@]}" 3>&1 1>&2 2>&3) || return + else + # only one option → auto-select + SELECTED="\"${choices[0]}\"" + msg_info "Auto-selecting GPU passthrough: ${choices[0]}" + fi - # export flags for install.sh for sel in $SELECTED; do case "$sel" in "\"VAAPI\"") @@ -51,7 +55,6 @@ select_hw_passthrough() { done } -# Apps that benefit from GPU passthrough (VAAPI + NVIDIA) # Apps that benefit from GPU passthrough (VAAPI + NVIDIA) _GPU_APPS=( immich