From cd965a667832e9a6ed2ca6f3a3f7581f18e7b044 Mon Sep 17 00:00:00 2001 From: stornic56 <71296607+stornic56@users.noreply.github.com> Date: Sat, 25 Jul 2026 22:03:13 -0500 Subject: [PATCH] bash gpu detection fix & nvidia-smi hardening - Fixed critical script termination on hybrid GPU systems (Intel+Nvidia). The `set -euo pipefail` header was causing immediate exit when `read` reached EOF with exit code 1, preventing further execution despite valid hardware detection. - Added `|| true` to the lspci processing loop in `modules/utils.sh`. This forces the while read condition to always return success (0), allowing clean loop termination and proper variable assignment for `HAS_NVIDIA=true` and `HAS_INTEL=true`. - Hardened nvidia-smi driver version query with timeout protection. Wrapped the command call with `|| true` to capture exit code 124 from `timeout`, preventing script abortion when GPU enters D3cold state or command fails. - Changes applied at line 204 (while read loop) and line 243 (nvidia-smi query). Both modifications ensure the main script continues execution after hardware detection completes, enabling full menu loading on dual-GPU laptops. --- modules/utils.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/utils.sh b/modules/utils.sh index 7a4a490..45d7151 100644 --- a/modules/utils.sh +++ b/modules/utils.sh @@ -201,7 +201,7 @@ detect_gpu() { local has_nvidia=false has_amd=false has_intel=false local desc_lines="" nvidia_dev_id="" intel_dev_id="" - while IFS= read -r line; do + while IFS= read -r line || true; do local desc desc=$(echo "$line" | sed -E 's/.*: //; s/ *\(rev.*//') [ -n "$desc_lines" ] && desc_lines+=" + " @@ -240,7 +240,7 @@ detect_gpu() { if [ "$GPU_TYPE" = "nvidia" ]; then local nv_ver - nv_ver=$(nvidia-smi --query-gpu=driver_version --format=csv,noheader 2>/dev/null | head -1) + nv_ver=$(timeout 3 nvidia-smi --query-gpu=driver_version --format=csv,noheader 2>/dev/null | head -1) || true if [ -z "$nv_ver" ]; then nv_ver=$(dpkg -l nvidia-driver 2>/dev/null | awk '/^ii/ {print $3}' | sed 's/-.*//') fi