fix(no-rgb): handle transient hardware unavailability during deploy
This commit is contained in:
@@ -17,13 +17,26 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
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
|
||||||
|
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
|
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 +44,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" ];
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user