@@ -35,18 +35,25 @@ function store_led() {
3535
3636 # In case the trigger is any of the kbd-*, don't store any other parameter
3737 # This avoids num/scroll/capslock from being restored at startup
38- # In case trigger is representing link-state for any network, don't store its previous state
39- # This avoids ghost wan/lan/etc (led up while cable unplugged)
40- [[ " $TRIGGER_VALUE " =~ kbd-* || " $TRIGGER_VALUE " == * " :link" ]] && return
38+ [[ " $TRIGGER_VALUE " =~ kbd-* ]] && return
4139
4240 COMMAND_PARAMS=" $CMD_FIND $PATH / -maxdepth 1 -type f ! -iname uevent ! -iname trigger -perm /u+w -printf %f\\ n"
4341 PARAMS=$( $COMMAND_PARAMS )
4442
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" / }
47+
4548 for PARAM in $PARAMS ; do
4649
4750 PARAM_PATH=" $PATH /$PARAM "
4851 VALUE=$( < $PARAM_PATH )
4952
53+ # If the variable contains non-printable characters
54+ # suppose it contains binary and skip it
55+ [[ " $VALUE " =~ [[:cntrl:]] ]] && continue
56+
5057 echo " $PARAM =$VALUE " >> $DESTINATION
5158
5259 done
@@ -60,9 +67,7 @@ for LED in /sys/class/leds/*; do
6067 [[ -d " $LED " ]] || continue
6168
6269 # Skip saving state for directories starting with enP e.g. enP1p1s0-0::lan enP2p1s0-2::lan etc. etc.
63- if [[ " $( /usr/bin/basename " $LED " ) " == enP* ]]; then
64- continue
65- fi
70+ [[ " $( /usr/bin/basename " $LED " ) " == enP* ]] && continue
6671
6772 store_led $LED $STATE_PATH
6873 echo >> $STATE_PATH
0 commit comments