fix(no-rgb): handle transient hardware unavailability during deploy
This commit is contained in:
@@ -17,13 +17,27 @@
|
||||
];
|
||||
|
||||
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
|
||||
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
|
||||
openrgb --noautoconnect --device "$i" --mode direct --color 000000
|
||||
openrgb --noautoconnect --device "$i" --mode direct --color 000000 || true
|
||||
done
|
||||
'';
|
||||
}
|
||||
@@ -31,9 +45,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" ];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user