mirror of
https://github.com/stornic56/debianito-post-install.git
synced 2026-10-31 13:08:06 +00:00
149fb56e8c
- `.github/workflows/ci.yml` added as a new workflow: job `lint-and-test` on `runs-on: ubuntu-latest` with `container: debian:trixie`, checking out via `actions/checkout@v4`, installing `bats` and `shellcheck`, running `shellcheck --severity=error debianito.sh modules/**/*.sh` (with `shopt -s globstar`) and `bats tests/`.
- `debianito.sh` CLI parser: `AUTO_YES=0`, `ALLOW_DESTRUCTIVE=0` declared after `MODULES_DIR` and before `_boot_mark`; `_usage()` prints `Usage: debianito.sh [OPTIONS]` with `--yes`, `--allow-destructive` and `--help`; the `while [ $# -gt 0 ]` / `case` loop consumes `--yes` and `--allow-destructive`, prints `Unknown option: $1 (run with --help for usage)` to stderr and `exit 2` for unknown flags, and `--help|-h` runs `_usage` then `exit 0`.
- `modules/utils.sh`: new global `_SELECTION_CONFIRMED=0` and `_confirm_install_list()` (utils.sh:756-785), which renders items capped at 15 with `... and N more`, computes `height` capped at 24, calls `_confirm "$title" "$list" "$height" 65`, arms `_SELECTION_CONFIRMED=${#items[@]}` on yes, and returns 1 for an empty list or on decline. `_install_pkg()` (utils.sh:789-804) decrements the countdown instead of prompting, and only prompts via `elif ! _confirm "Install: ${pkg}" "Install ${pkg}\nVersion: ${ver}?"; then return 0`.
- Bulk retrofit in `modules/extras/**/*.sh` (18 sites): `_confirm_install_list "Título" "${array[@]}" || return` placed right after the `whiptail` selection is parsed, the install loop left intact, and `_SELECTION_CONFIRMED=0` after the loop. Files: office/office.sh:101, system/software_centers.sh:29, system/system.sh:133, communication/communication.sh:68, design/design.sh:42, download/download.sh:48+55, terminals/terminals.sh:31, security/security.sh:30, players/players.sh:20, themes/fonts/fonts.sh:32, dev/dev.sh:44, programming/programming.sh:57, themes/desktop-themes/desktop-themes.sh:30, fetch/fetch.sh:41, themes/icons/icons.sh:47, themes/cursors/cursors.sh:28, internet/internet.sh:197, java.
- `modules/bullseye/extras.sh` (13 sites) plus `modules/bullseye/legacy.sh` (1 site, `install_gaming_bullseye`, guarded with `if [ ${#_install_pkgs[@]} -gt 0 ]` so a i386-only selection does not blank the summary) plus `modules/desktop_display.sh` (1 site, XFCE Custom — a no-loop `_run_cmd` batch with the reset immediately after it). Special cases: download.sh and bullseye/download each have two checklists merged into one combined summary; legacy.sh gaming skips the reset when the list is empty; XFCE Custom resets before `_xfce_polkit_rules` so the counter cannot leak.
- `modules/desktops/desktop_gnome.sh` (new): `gnome_menu()` runs a `_radiolist` with "1" "GNOME (Full Desktop)", "2" "GNOME Core (Minimal Install)", "3" "Back", then `_install_gnome_full()` and `_install_gnome_core()`. Each arms `_confirm_install_list "GNOME Full Desktop" gnome gdm3 || return` (core: `gnome-core gdm3`), keeps an already-configured display manager via `_existing_display_manager` by setting `target_dm="$keep_dm"`, writes the preseed `echo "${target_dm} shared/default-x-display-manager select ${target_dm}" | sudo debconf-set-selections`, installs `sudo apt install -y gnome gdm3` / `gnome-core gdm3`, enables `gdm3` only when `target_dm = "gdm3"`, resets `_SELECTION_CONFIRMED=0` and calls `_offer_pipewire_after_desktop`.
- `modules/desktops/desktop_kde.sh` (new): `kde_menu()` runs a `_radiolist` with "1" "KDE Plasma (Full Desktop)", "2" "KDE Plasma Desktop (Minimal)", "3" "Back"; `_install_kde_full()` and `_install_kde_minimal()` arm `_confirm_install_list "KDE Plasma Full" kde-standard sddm || return` (minimal: `kde-plasma-desktop sddm`), preseed `sddm shared/default-x-display-manager select sddm`, install `sudo apt install -y kde-standard sddm` / `kde-plasma-desktop sddm`, enable `sddm` only when it is the target DM, reset the counter and offer PipeWire.
- `modules/desktop_display.sh` `desktop_environment_menu()`: `env_items+=("3" "GNOME")`, `env_items+=("4" "KDE Plasma")`, `env_items+=("5" "Back")`; the case adds `3)` loading `gnome` via `_load_module gnome || continue` and calling `gnome_menu`, and `4)` loading `kde` via `_load_module kde || continue` and calling `kde_menu`; the dead TODO comment was removed.
- PipeWire retrofit in `modules/desktop_display.sh` (6 sites): `_install_lxde_full`, `_install_lxde_core`, `_install_xfce_full`, `_install_xfce_minimal`, `_install_xfce_wayland` and `_install_xfce_custom` each call `_offer_pipewire_after_desktop` after their install block.
- `_offer_pipewire_after_desktop()` and `_existing_display_manager()` added at the end of `modules/desktop_display.sh`: `_offer_pipewire_after_desktop` checks `pipewire-audio` (`pipewire` when `DEBIAN_VERSION = 11`), returns 0 via `is_installed`, otherwise `_confirm "PipeWire Audio" "No PipeWire audio server is installed.\n\nInstall the PipeWire audio stack (recommended)?"` calls `_install_pipewire_standard` and returns 0. `_existing_display_manager` reads `${DM_FILE:-/etc/X11/default-display-manager}`, reads the basename as the DM, and otherwise scans `gdm3 lightdm sddm greetd gdm` with `systemctl is-enabled`, printing nothing when none is found.
- `_ensure_apt_updated` added before the GNOME/KDE `apt install` transactions (4 sites, deduplicated per session); `gnome gdm3` and `kde-standard sddm` are installed alongside even when another display manager is kept as the default.
- Extraction to `modules/desktops/`: `desktop_lxde.sh` (38 lines) and `desktop_xfce.sh` (119 lines) created with the `lxde_menu` / `_install_lxde_full` / `_install_lxde_core` and `xfce_menu` / `_install_xfce_full` / `_install_xfce_minimal` / `_install_xfce_wayland` / `_install_xfce_custom` / `_xfce_polkit_rules` blocks moved verbatim; both carry `# License GPL v3` in their headers.
- `modules/desktop_display.sh` reduced from 542 to 394 lines (−154): lines 55-208 removed, the dispatch (desktop_display.sh:39-46) replaced with `_load_module xfce || continue` / `lxde_menu`, and the file left with `manage_desktop_display`, `desktop_environment_menu`, `display_manager_menu`, `lightdm_config_menu`, `configure_greetd`, `configure_gdm3`, `configure_sddm`, the two shared helpers.
- `modules/utils.sh` `_load_module` map: `xfce)` → `${MODULES_DIR}/desktops/desktop_xfce.sh`, `lxde)` → `${MODULES_DIR}/desktops/desktop_lxde.sh`, `gnome)` → `${MODULES_DIR}/desktops/desktop_gnome.sh`, `kde)` → `${MODULES_DIR}/desktops/desktop_kde.sh`; deps for `xfce`, `lxde`, `gnome` and `kde` are `(desktop_display audio)` and `desktop_display` is `(repos audio)`.
- `modules/desktops/desktop_xfce.sh` `_xfce_polkit_rules()` writes `/etc/polkit-1/rules.d/85-suspend.rules` and `89-backlight.rules` via `sudo tee`, adds the `backlight` group with `groupadd --system` fallback, adds the real login user from `/etc/passwd` to `backlight` and restarts `polkit.service`.
- ES→EN user-facing strings: 14 strings across 4 files — `desktop_display.sh` `lxdе_menu` ("LXDE (Full Desktop)", "LXDE Core (Minimal Install)"), `gpu/nvidia.sh` Kepler legacy-driver notice ("Kepler GPU detected (GKxxx)… Install the legacy driver for Kepler?"), `bullseye/legacy.sh` ("Install NVIDIA driver?", "Skipping NVIDIA driver.", "Installing NVIDIA driver ${gpu_gen}...") and `bullseye/extras.sh` ("firmware-linux-nonfree provides drivers for… Install?").
- ES→EN internal comments: ~35 comments across 9 files — section headers in `_install_nvidia_standard`, `gpu/_helpers.sh` (lines 5, 113), `gpu/nvidia.sh` (lines 8-12, 19-22, 68-70, 167-172, 196, 239-253, 262-263, 275, 291, 336-338, 376), `gpu.sh` (lines 15-17), `bullseye/repos.sh` (line 2), `firmware.sh` (line 235, "--- Load verification ---"), `utils.sh` (lines 129, 132, 153 — timezone Paso 1/2/4) and `utils.sh:546,548`.
- set -e abort fix: `debianito.sh:149` now reads `_system_preferences_menu || true`, consistent with the other dispatch chains (14 of the 15 chains already had the guard); a declined pre-apply summary now leaves the TUI alive instead of terminating the script.
- `docs/desktops_display.md`: 4 hunks — intro now lists GNOME/GNOME Core/KDE Plasma/KDE Plasma Desktop/XFCE/XFCE Wayland/XFCE Custom/LXDE, a new "Modular layout" paragraph describing `modules/desktops/` and lazy loading, Block 1 rewritten into four environments, five new bullets (pre-apply summary, existing-DM preservation, PipeWire offer, stale-lists guard) and a Desktop Environment Packages table.
- `docs/quickstart.md` line 284: Desktop Environment entry expanded to pick from XFCE (full / minimal / Wayland `labwc` on Trixie / custom checklist), LXDE (full / core), GNOME (full / core) or KDE Plasma (full / minimal).
- `_existing_display_manager` now takes the config path via `local dm_file="${DM_FILE:-/etc/X11/default-display-manager}"` so the offline test suite never reads the real system file.
- `tests/test_helper.bash`: added `_mock_systemctl()` for `is-enabled` (units in `MOCK_SYSTEMCTL_ENABLED` report `enabled`, everything else `disabled`), `MOCK_SYSTEMCTL_ENABLED=""`, `WHIPTAIL_CALLS`/`MOCK_WHIPTAIL_OUTPUT`/`MOCK_WHIPTAIL_RC`, `MOCK_DPKG_INSTALLED` and the `systemctl` entry in the mock list and in `mock_reset()`.
- `tests/desktops.bats` created with 16 tests: `_existing_display_manager` (file read, file-preferred over an enabled unit, enabled-unit fallback, candidate order, missing file, nothing configured), `_offer_pipewire_after_desktop` (5 tests: skip-installed, accept-installs, decline-returns-0, Bullseye package name, wrong package name on 11), `_load_module` (4 tests for xfce/lxde/gnome/kde) and an unknown-module case; 17→33 tests total.
- `.github/workflows/ci.yml` shellcheck severity raised from `--severity=error` to `--severity=warning`.
- `debianito.sh`: `RED`, `GREEN`, `YELLOW`, `CYAN` and `NC` plus `AUTO_YES`, `ALLOW_DESTRUCTIVE` and `DEBIAN_CODENAME` are now `export`ed as cross-file globals.
- `modules/utils.sh`: `HAS_NVIDIA`, `DESKTOP_ENV`, `AUDIO_SERVER`, `DEBIAN_VERSION` and the other cross-file globals are `export`ed.
- `modules/extras/system/software_centers.sh` gained a `#!/usr/bin/env bash` shebang.
- `shellcheck` triage (v0.11.0, baseline `--severity=warning` 25 findings → 0): removed two dead-code lines (`headless` in `extras/dev/dev.sh`, orphan `dev_id` in `firmware.sh`); `SC2206` in `extras/dev/essential.sh` fixed by expanding `$comp_pkgs` to `"${comp_pkgs[@]}"`; `SC2010`/`SC2046` (3 sites) replaced `ls … | grep` with `compgen -G "…"`; `SC2155` (2 sites, `gpu.sh` and `rescue.sh`) split command substitutions into separate lines; `SC2166` in `repos.sh` replaced `-o` with `{ … || … }`; `SC2221`/`SC2222` (2 sites, `sysinfo.sh` and `utils.sh`) collapsed the `wl*|wlp*|wlo*|wlan*` alternation to `wl*`; `SC1090` in `extras.sh` gained a justification comment on the disable directive.
- Final verification: `bash -n` on all 15 modified `.sh` files and `set -euo pipefail` at `debianito.sh:3` both intact; `bats tests/` reports 33 ok / 0 failed; invariants `offers 11`, `confirm_install_list 39` and `_SELECTION_CONFIRMED=0 40` hold.
205 lines
8.8 KiB
Bash
205 lines
8.8 KiB
Bash
#!/usr/bin/env bash
|
|
# Shared helpers for GPU submodules
|
|
|
|
declare -A NVIDIA_FAMILY_MAP=(
|
|
# Fermi / Kepler (Legacy: the shim separates them)
|
|
["06"]="legacy" ["0D"]="legacy" ["0E"]="legacy"
|
|
["0F"]="legacy" ["10"]="legacy" ["11"]="legacy" ["12"]="legacy"
|
|
# Maxwell
|
|
["13"]="maxwell" ["14"]="maxwell" ["16"]="maxwell" ["17"]="maxwell"
|
|
# Pascal + Volta (same classic driver policy)
|
|
["15"]="pascal" ["1B"]="pascal" ["1C"]="pascal" ["1D"]="pascal"
|
|
# Turing
|
|
["1E"]="turing" ["1F"]="turing" ["21"]="turing"
|
|
# Ampere
|
|
["20"]="ampere" ["22"]="ampere" ["24"]="ampere" ["25"]="ampere"
|
|
# Hopper
|
|
["23"]="hopper"
|
|
# Ada Lovelace
|
|
["26"]="ada" ["27"]="ada" ["28"]="ada"
|
|
# Blackwell
|
|
["29"]="blackwell" ["2B"]="blackwell" ["2C"]="blackwell"
|
|
["2D"]="blackwell" ["2E"]="blackwell" ["31"]="blackwell"
|
|
)
|
|
|
|
detect_nvidia_arch() {
|
|
[ -z "$1" ] && {
|
|
echo "unknown"
|
|
return
|
|
}
|
|
local pci_id="${1^^}"
|
|
local prefix="${pci_id:0:2}"
|
|
echo "${NVIDIA_FAMILY_MAP[$prefix]:-unknown}"
|
|
}
|
|
|
|
_is_nvidia_kepler_id() {
|
|
local dev_id="$1"
|
|
[ -z "$dev_id" ] && return 1
|
|
local dev_int=$((16#${dev_id,,}))
|
|
[ "$dev_int" -ge $((16#0FC0)) ] && [ "$dev_int" -le $((16#0FFF)) ] && return 0
|
|
[ "$dev_int" -ge $((16#1000)) ] && [ "$dev_int" -le $((16#103F)) ] && return 0
|
|
[ "$dev_int" -ge $((16#1180)) ] && [ "$dev_int" -le $((16#11FF)) ] && return 0
|
|
[ "$dev_int" -ge $((16#1280)) ] && [ "$dev_int" -le $((16#12BF)) ] && return 0
|
|
return 1
|
|
}
|
|
|
|
# Normalizes the NVIDIA architecture family, disambiguating Kepler/Fermi
|
|
# (detect_nvidia_arch groups them as "legacy" via device-ID range)
|
|
_get_nvidia_arch_family() {
|
|
local fam
|
|
fam=$(detect_nvidia_arch "$NVIDIA_GPU_DEVICE_ID")
|
|
if [ "$fam" = "legacy" ]; then
|
|
if _is_nvidia_kepler_id "$NVIDIA_GPU_DEVICE_ID"; then
|
|
echo "kepler"
|
|
else
|
|
echo "fermi"
|
|
fi
|
|
else
|
|
echo "$fam"
|
|
fi
|
|
}
|
|
|
|
is_nvidia_kepler() { [ -n "$NVIDIA_GPU_DEVICE_ID" ] && [[ "$(detect_nvidia_arch "$NVIDIA_GPU_DEVICE_ID")" == "legacy" ]] && _is_nvidia_kepler_id "$NVIDIA_GPU_DEVICE_ID" && echo true || echo false; }
|
|
is_nvidia_fermi() { [ -n "$NVIDIA_GPU_DEVICE_ID" ] && [[ "$(detect_nvidia_arch "$NVIDIA_GPU_DEVICE_ID")" == "legacy" ]] && ! _is_nvidia_kepler_id "$NVIDIA_GPU_DEVICE_ID" && echo true || echo false; }
|
|
is_nvidia_legacy() { [ -n "$NVIDIA_GPU_DEVICE_ID" ] && [[ "$(detect_nvidia_arch "$NVIDIA_GPU_DEVICE_ID")" == "legacy" ]] && echo true || echo false; }
|
|
is_nvidia_maxwell() { [ -n "$NVIDIA_GPU_DEVICE_ID" ] && [[ "$(detect_nvidia_arch "$NVIDIA_GPU_DEVICE_ID")" == "maxwell" ]] && echo true || echo false; }
|
|
is_nvidia_pascal() { [ -n "$NVIDIA_GPU_DEVICE_ID" ] && [[ "$(detect_nvidia_arch "$NVIDIA_GPU_DEVICE_ID")" == "pascal" ]] && echo true || echo false; }
|
|
is_nvidia_volta() { [ -n "$NVIDIA_GPU_DEVICE_ID" ] && [[ "$(detect_nvidia_arch "$NVIDIA_GPU_DEVICE_ID")" == "volta" ]] && echo true || echo false; }
|
|
is_nvidia_turing() { [ -n "$NVIDIA_GPU_DEVICE_ID" ] && [[ "$(detect_nvidia_arch "$NVIDIA_GPU_DEVICE_ID")" == "turing" ]] && echo true || echo false; }
|
|
is_nvidia_ampere() { [ -n "$NVIDIA_GPU_DEVICE_ID" ] && [[ "$(detect_nvidia_arch "$NVIDIA_GPU_DEVICE_ID")" == "ampere" ]] && echo true || echo false; }
|
|
is_nvidia_ada() { [ -n "$NVIDIA_GPU_DEVICE_ID" ] && [[ "$(detect_nvidia_arch "$NVIDIA_GPU_DEVICE_ID")" == "ada" ]] && echo true || echo false; }
|
|
is_nvidia_blackwell() { [ -n "$NVIDIA_GPU_DEVICE_ID" ] && [[ "$(detect_nvidia_arch "$NVIDIA_GPU_DEVICE_ID")" == "blackwell" ]] && echo true || echo false; }
|
|
|
|
is_amd_legacy_gcn() {
|
|
local dev_id
|
|
dev_id=$(echo "$LSPCI_OUTPUT" | grep -iE "VGA|3D" | grep -i amd | grep -oP '1002:\K[0-9a-fA-F]{4}' | head -n1)
|
|
[ -z "$dev_id" ] && {
|
|
echo false
|
|
return
|
|
}
|
|
|
|
local legacy_ids
|
|
legacy_ids="6660|6664|6665|6667|6780|6784|6788|678a|6798|679a|679e|679f|3000|3001|6808|6809|6810|6811|6816|6817|6818|6819|6828|6829|682b|682c|6835|6837|683d|683f|6608|6609|6610|6611|6613|6617|1dcf|983d|6646|6649|664d|6650|6651|6658|665c|665d|67a0|67a1|67a2|67a8|67a9|67aa|67b0|67b1|67b8|67be|9830|9831|9832|9833|9834|9835|9836|9837|9838|9839|1304|1305|1306|1307|1309|130a|130b|130c|130d|130e|130f|1310|1311|1312|1313|1315|1316|1317|1318|131b|131c|131d|9850|9851|9852|9853|9854|9855|9856|9857|9858|9859|985a|985b|985c|985d|985e|985f"
|
|
|
|
if echo "$dev_id" | grep -qiE "^(${legacy_ids})$"; then
|
|
echo true
|
|
else
|
|
echo false
|
|
fi
|
|
}
|
|
|
|
_install_mesa_backports() {
|
|
if [ "$(is_backports_enabled)" != "true" ]; then
|
|
install_mesa_stable
|
|
return
|
|
fi
|
|
|
|
local mesa_pkgs=("mesa-vulkan-drivers" "libgl1-mesa-dri" "libglx-mesa0" "libegl-mesa0" "mesa-va-drivers")
|
|
local bpo_pkgs=()
|
|
local stable_pkgs=()
|
|
|
|
for mpkg in "${mesa_pkgs[@]}"; do
|
|
local bpo_ver
|
|
bpo_ver=$(apt-cache madison "$mpkg" 2>/dev/null |
|
|
grep "${DEBIAN_CODENAME}-backports" | awk '{print $3}' | head -1)
|
|
if [ -n "$bpo_ver" ]; then
|
|
bpo_pkgs+=("$mpkg")
|
|
else
|
|
stable_pkgs+=("$mpkg")
|
|
fi
|
|
done
|
|
|
|
# Mesa >= 25.3.3 unified VA-API into mesa-libgallium.
|
|
# mesa-va-drivers from backports breaks with the new mesa-libgallium.
|
|
local _bpo_filtered=()
|
|
for _p in "${bpo_pkgs[@]}"; do
|
|
[ "$_p" != "mesa-va-drivers" ] && _bpo_filtered+=("$_p")
|
|
done
|
|
bpo_pkgs=("${_bpo_filtered[@]}")
|
|
|
|
local ref_ver
|
|
ref_ver=$(apt-cache policy mesa-vulkan-drivers 2>/dev/null | awk 'NR==3 {print $2; exit}')
|
|
local ref_bpo_ver
|
|
ref_bpo_ver=$(apt-cache madison mesa-vulkan-drivers 2>/dev/null |
|
|
grep "${DEBIAN_CODENAME}-backports" | awk '{print $3}' | head -1)
|
|
local comp_line="Components: Vulkan, OpenGL, GLX, EGL, VA-API (64-bit)"
|
|
|
|
if [ ${#bpo_pkgs[@]} -gt 0 ]; then
|
|
local src_label="Debian ${DEBIAN_CODENAME^}-Backports"
|
|
[ ${#stable_pkgs[@]} -gt 0 ] && src_label+=" + Stable"
|
|
local msg="Mesa provides OpenGL/Vulkan/VA-API acceleration.\n\n"
|
|
msg+="Source: ${src_label}\n"
|
|
msg+="Mesa ${ref_bpo_ver:-$ref_ver}\n"
|
|
msg+="${comp_line}\n\n"
|
|
[ ${#stable_pkgs[@]} -gt 0 ] && msg+="Some packages only available in stable.\n"
|
|
msg+="Choose version for backports-capable packages:"
|
|
if _confirm_custom "Mesa (Graphics)" "$msg" "Backports" "Stable" 14 70; then
|
|
_run_cmd "Mesa (backports)" "sudo apt install -y -t ${DEBIAN_CODENAME}-backports ${bpo_pkgs[*]}" \
|
|
"Installing Mesa from backports..."
|
|
if [ ${#stable_pkgs[@]} -gt 0 ]; then
|
|
_run_cmd "Mesa (stable)" "sudo apt install -y ${stable_pkgs[*]}" \
|
|
"Installing remaining Mesa packages from stable..."
|
|
fi
|
|
else
|
|
_run_cmd "Mesa" "sudo apt install -y ${mesa_pkgs[*]}" \
|
|
"Installing Mesa from stable..."
|
|
fi
|
|
else
|
|
local msg="Mesa provides OpenGL/Vulkan/VA-API acceleration.\n\n"
|
|
msg+="Source: Debian Stable\n"
|
|
msg+="Mesa ${ref_ver}\n"
|
|
msg+="${comp_line}\n\n"
|
|
msg+="Install Mesa from available repositories?"
|
|
if _confirm "Mesa (Graphics)" "$msg" 14 70; then
|
|
_run_cmd "Mesa" "sudo apt install -y ${mesa_pkgs[*]}" \
|
|
"Installing Mesa..."
|
|
fi
|
|
fi
|
|
}
|
|
|
|
install_mesa_stable() {
|
|
local mesa_pkgs=("mesa-vulkan-drivers" "libgl1-mesa-dri" "libglx-mesa0" "libegl-mesa0" "mesa-va-drivers")
|
|
_run_cmd "Mesa" "sudo apt install -y ${mesa_pkgs[*]}" "Installing Mesa from stable..."
|
|
}
|
|
|
|
offer_generic_tools() {
|
|
if [ "$DEBIAN_VERSION" = "11" ]; then
|
|
if ! lsmod 2>/dev/null | grep -q "^nvidia "; then
|
|
echo "nvtop skipped on Bullseye — NVIDIA driver not loaded."
|
|
return
|
|
fi
|
|
fi
|
|
local tool_pkgs
|
|
tool_pkgs=$(pkg_versions nvtop vainfo)
|
|
if _confirm "GPU Tools" "Install monitoring and info tools?\n\n${tool_pkgs}"; then
|
|
_run_cmd "GPU Tools" "sudo apt install -y nvtop vainfo" "Installing GPU tools..." || true
|
|
if command -v vainfo &>/dev/null; then
|
|
vainfo
|
|
_pause "vainfo output shown above."
|
|
else
|
|
echo -e "${YELLOW}vainfo not available, skipping report.${NC}"
|
|
fi
|
|
else
|
|
echo "Skipping GPU monitoring tools."
|
|
fi
|
|
}
|
|
|
|
_is_hybrid_laptop() {
|
|
local gpu_count nvidia_count chassis
|
|
gpu_count=$(echo "$LSPCI_OUTPUT" | grep -ciE "VGA compatible|3D controller") || true
|
|
[ "$gpu_count" -lt 2 ] && return 1
|
|
|
|
# Defense in depth: if ALL GPUs are NVIDIA (SLI or dual-GPU
|
|
# desktop), there is no Intel/AMD iGPU → not hybrid.
|
|
nvidia_count=$(echo "$LSPCI_OUTPUT" | grep -iE "VGA compatible|3D controller" | grep -c "10de:") || true
|
|
[ "$nvidia_count" -ge "$gpu_count" ] && return 1
|
|
|
|
chassis=$(cat /sys/class/dmi/id/chassis_type 2>/dev/null || echo "0")
|
|
case "$chassis" in
|
|
8 | 9 | 10 | 11 | 14 | 30 | 31 | 32) return 0 ;;
|
|
esac
|
|
|
|
compgen -G "/sys/class/power_supply/BAT*" >/dev/null && return 0
|
|
return 1
|
|
}
|