fix(no-rgb): handle transient hardware unavailability during deploy

This commit is contained in:
2026-02-12 18:44:32 -05:00
parent 9e706b5731
commit e87dab1f34

View File

@@ -17,13 +17,27 @@
]; ];
text = '' text = ''
#!/bin/sh # Retry loop to wait for hardware to be ready
set -e NUM_DEVICES=0
for attempt in 1 2 3 4 5; do
DEVICE_LIST=$(openrgb --noautoconnect --list-devices 2>/dev/null) || DEVICE_LIST=""
NUM_DEVICES=$(echo "$DEVICE_LIST" | grep -cE '^[0-9]+: ') || NUM_DEVICES=0
if [ "$NUM_DEVICES" -gt 0 ]; then
break
fi
if [ "$attempt" -lt 5 ]; then
sleep 2
fi
done
NUM_DEVICES=$(openrgb --noautoconnect --list-devices | grep -cE '^[0-9]+: ') # If no devices found after retries, exit gracefully
if [ "$NUM_DEVICES" -eq 0 ]; then
exit 0
fi
# Disable RGB on each device
for i in $(seq 0 $((NUM_DEVICES - 1))); do for i in $(seq 0 $((NUM_DEVICES - 1))); do
openrgb --noautoconnect --device "$i" --mode direct --color 000000 openrgb --noautoconnect --device "$i" --mode direct --color 000000 || true
done done
''; '';
} }
@@ -31,9 +45,12 @@
in in
{ {
description = "disable rgb"; description = "disable rgb";
after = [ "systemd-udev-settle.service" ];
serviceConfig = { serviceConfig = {
ExecStart = lib.getExe no-rgb; ExecStart = lib.getExe no-rgb;
Type = "oneshot"; Type = "oneshot";
Restart = "on-failure";
RestartSec = 5;
}; };
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
}; };