FEATURE REQ: WiFi on/off with side switch?


So this seems basic but it would be incredibly useful to me. The current 2 options are VPN on/off or switch between bridge/router modes. Which are also quite useful. But in my use case here, I would love to be able to disable (and enable) the WiFi radio on AR300M with the side slider switch rather than having to ping the web interface to make the adjustment. Any chance?

Configuring the "switch button" to disable wifi radio

The switch can be programmed to do whatever you like. Just do a forum search on it and you will see!


Find the script of the switch button under /etc/rc.button/

You can also find /etc/init.d/init_switch


OK but how does one go about changing the function? I’m not a Linux expert and not real familiar with LuCi and working at the command prompt level. I just want to change to allow WiFi on/off with the side button toggle as opposed to VPN or router/bridge mode as default options.


Agreed this would be a great feature to be included… im not sure how to do this either. Any ideas?


Here is how you can do it, manually.

Find /etc/init.d/initswitch

Turn on wifi when switch on left side

Line 57:

uci set wirless.@wifi-iface[0].disabled=0
uci commit wireless
wifi on

Turn off wifi when switch on left side
Line 70 (before editing):

uci set wirless.@wifi-iface[0].disabled=1
uci commit wireless
wifi off


Wow already had it down. Thank you so much alzaho, you are so very helpful!


Hello, I’m a fresh new and happy GL.iNet user (owner of a GL-MT300N-V2). I apologize in advance for the length of this post because I’ve dig around and I’ve discovered many things but not all I need. As other users in this topic I wanted to use the hardware switch to enable/disable wifi. I think things has changed because I don’t have any /etc/init.d/initswitch script in my device. I managed to get the result but I don’t like the solution because I had to force some variables value in /usr/bin/switchaction and this could break some functionalities.
Firmware version: 3.012
What I’ve discovered:

  • commands wifionoff on/off work fine to enable/disable wifi
  • the switch fires /etc/rc.button/BTN_0 (I think but I’m not sure) which print something to /dev/console and fires /usr/bin/switchaction
  • /usr/bin/switchaction reads get glconfig.switch_button.enable and glconfig.switch_button.function variables to decide if and what it has to do
  • glconfig.switch_button.function by factory contains “”, not “noop” or something like this (bug?)
  • when we interact with the web interface (MORE SETTINGS>Button Settings) the actions to set the variables start from /usr/share/glweb1/web/src/temple/settings/index.js

What I miss:

  • which script actually set the variables read in /usr/bin/switchaction after /usr/share/glweb1/web/src/temple/settings/index.js has been called


In v3.x firmware, the shell script to operate the slide switch is /usr/bin/switchaction. Actually, you can remove this shell script, and rewrite one.

mv /usr/bin/switchaction /usr/bin/switchaction.bak
touch /usr/bin/switchaction && chmod +x /usr/bin/switchaction
vi /usr/bin/switchaction

Add those line into /usr/bin/switchaction, it will looks like:


switch_action() {
        local switch_left=$(grep -o "BTN_0.*hi" /sys/kernel/debug/gpio)

        if [ -n "$switch_left" ]; then
                # Switch to left
                # TODO
                # Switch to right
                # TODO



Thank you for your reply. Yes, I’ve already done that, but it’s not exactly what I’m trying to do. It breaks the web interface selector for the switch behaviour. I’d like instead to preserve the possibility of selecting it from the web interface, and I’d like to add an entry to select “WiFi on/off” to it.


Then you can edit /usr/bin/switchaction and web UI source code to achieve this.

This needs a little skills but you don’t have to wait.