Wayland compositor (wlroots)
git clone https://git.lucas.co/cce-compositor.git
scripts/gpu-watcher (1K)
1 #!/usr/bin/env bash
2
3 # Make sure we have a log of the startup
4 echo "NVIDIA GPU Wedge Watcher started at $(date)"
5
6 # Ensure DBus connection is available for notify-send when run under systemd
7 if [ -z "$DBUS_SESSION_BUS_ADDRESS" ]; then
8 export DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$(id -u)/bus"
9 fi
10
11 # Watch kernel logs event-driven
12 journalctl --follow -k -o cat | while read -r line; do
13 if [[ "$line" == *"fallen off the bus"* ]]; then
14 echo "ALERT: GPU fell off the bus: $line"
15 notify-send -u critical -i "dialog-error" \
16 "NVIDIA GPU Failure" \
17 "GPU has fallen off the PCIe bus. A system reboot is required."
18 elif [[ "$line" == *"NVRM: Xid"* ]]; then
19 # Try to extract the Xid number
20 xid=$(echo "$line" | grep -o 'Xid [0-9]\+' | cut -d' ' -f2)
21 echo "ALERT: GPU Xid error detected: Xid $xid"
22 notify-send -u critical -i "dialog-warning" \
23 "NVIDIA GPU Xid $xid Error" \
24 "Driver reported a critical error.\nDetails: $line"
25 fi
26 done