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 f79ff4ade6

View File

@@ -17,13 +17,26 @@
];
text = ''
#!/bin/sh
set -e
# Retry loop to wait for hardware to be ready
NUM_DEVICES=0
for attempt in 1 2 3 4 5; do
NUM_DEVICES=$(openrgb --noautoconnect --list-devices 2>/dev/null | grep -cE '^[0-9]+: ' || echo 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
openrgb --noautoconnect --device "$i" --mode direct --color 000000
openrgb --noautoconnect --device "$i" --mode direct --color 000000 || true
done
'';
}
@@ -31,9 +44,12 @@
in
{
description = "disable rgb";
after = [ "systemd-udev-settle.service" ];
serviceConfig = {
ExecStart = lib.getExe no-rgb;
Type = "oneshot";
Restart = "on-failure";
RestartSec = 5;
};
wantedBy = [ "multi-user.target" ];
};