The hardware.button wiki page lists KEY_LIGHTS_TOGGLE as one of the supported keys, for which I can add a script in /etc/rc.button/lights_toggle.
To disable the LED(s), I could probably just loop over all buttons and set trigger to 'none' and default to '0'. That would mean I lost all user config though, so I'll have a look at how to avoid that.
Edit: Found a similar use case for KEY_LIGHTS_TOGGLE
Edit:
DTS entry:
led {
label = "LED button";
linux,code = <KEY_LIGHTS_TOGGLE>;
gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
debounce-interval = <60>;
};
Button handler script for the TP-Link EAP225-Wall:
#!/bin/sh
[ "${ACTION}" = "released" ] || exit 0
LED_PATH="/sys/class/leds/tp-link:white:status/brightness"
CURRENT=$(cat $LED_PATH)
if [[ $CURRENT == 0 ]]; then
echo 255 > $LED_PATH
else
echo 0 > $LED_PATH
fi
return 0