Skip to content

Commit 16a21ae

Browse files
committed
fix(armbian-leds): don't persist brightness for any active trigger
armbian-led-state-save.sh wrote brightness for every LED with a writable brightness file. For LEDs whose trigger is active (e.g. disk-activity, heartbeat, phy0tpt, eth0:link, mmc0, cpu, timer, pattern, usb-*, nand-disk) brightness is the trigger's instantaneous output (a momentary blink-state captured at shutdown), not configuration. Persisting it produced ghost-LED bugs on restore (cable-up while unplugged, rtw88 wifi flapping 0/1) and constant noise in /etc/armbian-leds.conf on every shutdown — visible to anyone with etckeeper / etc-diff alerts. Fix: strip brightness whenever trigger != none. The previous workaround stripped only \`*:link\` triggers (commit 2960ffa) and is now subsumed. trigger=none preserves brightness as before (it is genuine config there). Token-safe filter (whole-word match, not substring): the original substitution \${PARAMS//brightness/} would corrupt sibling files like \`max_brightness\` -> \`max_\`, breaking the read loop under set -e. Bash-only loop because store_led() reassigns PATH to the sysfs led path, so external commands wouldn't be found here. Forum thread: https://forum.armbian.com/topic/57284- Restore-script's brightness=0 skip guard becomes redundant for active triggers but harmless. Assisted-by: Claude:claude-opus-4.7
1 parent 3ceb3be commit 16a21ae

1 file changed

Lines changed: 23 additions & 4 deletions

File tree

packages/bsp/common/usr/lib/armbian/armbian-led-state-save.sh

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,29 @@ function store_led() {
4040
COMMAND_PARAMS="$CMD_FIND $PATH/ -maxdepth 1 -type f ! -iname uevent ! -iname trigger -perm /u+w -printf %f\\n"
4141
PARAMS=$($COMMAND_PARAMS)
4242

43-
# In case trigger is representing link-state for any network, use
44-
# bash substitution to remove the brightness parameter and avoid
45-
# ghost wan/lan/etc (led up while cable unplugged)
46-
[[ "$TRIGGER_VALUE" == *":link" ]] && PARAMS=${PARAMS//"brightness"/}
43+
# brightness has two distinct meanings depending on the trigger:
44+
# trigger=none → brightness is config (static value, persist it).
45+
# trigger=* → brightness is the trigger's instantaneous output
46+
# (blink-state at shutdown), persisting it is noise
47+
# and causes ghost-LED bugs on restore (e.g. ":link"
48+
# triggers showed cable-up while unplugged; rtw88
49+
# wifi flapped 0/1 in /etc/armbian-leds.conf on every
50+
# shutdown). Strip for any non-none trigger.
51+
# Subsumes the earlier ":link"-only workaround (commit 2960ffaff).
52+
# Forum thread: https://forum.armbian.com/topic/57284-
53+
# Token-safe filter (whole-word match): the previous ${PARAMS//brightness/}
54+
# substring substitution would also corrupt sibling files like
55+
# `max_brightness` -> `max_`, breaking the read loop below under set -e.
56+
# Bash-only (no `awk` etc.) because store_led() reassigns PATH to the
57+
# sysfs led path, so external commands wouldn't be found here.
58+
if [[ "$TRIGGER_VALUE" != "none" ]]; then
59+
declare _filtered=""
60+
for _p in $PARAMS; do
61+
[[ "$_p" == "brightness" ]] && continue
62+
_filtered+="$_p"$'\n'
63+
done
64+
PARAMS="$_filtered"
65+
fi
4766

4867
for PARAM in $PARAMS; do
4968

0 commit comments

Comments
 (0)