#!/usr/bin/env nu # SPDX-License-Identifier: AGPL-3.0-only # Copyright (c) 2025 MatrixFurry use std/log # Detect issues with the GPU. # # This was created for my own use on a Framework Laptop 16 with an external dock. # Sometimes, the external GPU will have issues caused by my hacky m.2 to oculink adapter. # # I can't guarantee this will work for you, but it does reliably detect when there is an issue on my system. export def main [] { let vkinfo = vulkaninfo --summary o+e>| $in if ($vkinfo | str contains "Could not open device /dev/dri/renderD128") or ($vkinfo | str contains "failed to open device /dev/dri/renderD128") { report "Could not access GPU rendering subsystem" } if ($vkinfo | lines | parse " deviceType{whitespace}= {device_type}" | where device_type == "PHYSICAL_DEVICE_TYPE_DISCRETE_GPU" | length) == 0 { report "Discrete GPU not found" } } def report [ message: string ] { log warning $"GPU Issue Detected: ($message)" job spawn { match (notify-send -u critical "GPU Issue Detected" $message -A reboot="Reboot") { reboot => (systemctl reboot) } } null }