Sliding switch setting at boot w/ procd

Hi, I'm setting up a gl-inet mango v2, and I want the switch to control the AP network.
It seemed to me that procd was the recommended way, and with the docs this is what I put in /etc/rc.button/BTN_0:

#!/bin/sh

case "$ACTION" in
released)
	uci set wireless.ap.disabled='1'
;;
pressed)
	uci del wireless.ap.disabled
;;
esac

# update wifi
wifi

return 0

This works mostly fine, except that when I reboot it the configuration sets it to on, and this script doesn't run until the switch is flipped again.
I could do uci commit every time so it stores state across reboots, but it still won't detect the switch position on boot, so if I flip the switch before I power it on it wouldn't detect it obviously.

What's the proper way to do this? I rather not install more packages.

If it's really a switch an no button then the device tree is missing the property linux,input-type = <EV_SW>; inside the node BTN_0.

This is the related definition inside the device tree for your device:

If this button is officially intended for switch wifi on or off you can assign also the correct input code like here:


With this key code set you won't require your hotplug script!

If it's really a switch an no button

Interesting. I'll try changing it to switch, how would I configure it then? I saw somewhere in the docs that you can have the configuration in /etc/config/system, not sure how...

If this button is officially intended for switch wifi on or off you can assign also the correct input code like here:

I don't think it's officially intended to do anything, looks like it was meant to be customized. At any rate, I don't want it to rfkill the wifi, I'm keeping the station link on, as that's my uplink, I'm just disabling the AP as I don't really need it

there is a package called slide-switch to use sliding switch functionality. You can install it with opkg.

I think it is the same as your script (it supports more devices of course), but it also adds a init script in /etc/init.d/ and enables it with service xxxxx enable, so that on boot it will check the status of the slide switch and trigger the actions.

You can see here the source (it is a script so you can copy what it does if you want) and read the documentation