Auto-select GPU passthrough when only one option
Some checks failed
Bump build.func Revision / bump-revision (push) Has been cancelled

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.
This commit is contained in:
CanbiZ 2025-09-22 14:30:16 +02:00
parent 3d09942544
commit 020f55e26c

View File

@ -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