I am running some custom scripts on my Slate that I would like to enable and disable using the hardware switch on the side of the router. I thought it would be a good idea to customise the GLInet WebUI and add another option to the button settings. VueJS is very familiar to me so I made the UI changes OK but I am stuck where the VueJS layer calls the /cgi-bin/api/router/switch/set API. I don’t have the source code for that so I am guessing at the parameters and hoping it will make the appropriate updates to the UCI glconfig.switch_button settings. Unfortunately I can’t get it to save my custom settings.
Can I find out more about this API? The parameters, what it does, the source code?
Is there another API I can call to just simply set a UCI parameter?
here is where I ended up with buttons and switches.
easy and hardway
easy way for four scripts or less
go to /usr/bin/button_released
and switch network reload or factory default with your script and play with the button released time settings if you want more by adding more (larger times at top down)
hardway for 8 or more scripts
I’m going to tell you where you want to end up and why.
you want to use the reset button in conjunction with the slide switch.
if you press the reset button less then 1 second you look at the switch setting of left or right and launch 1 of two choices. usually you can combine 1 switch enable and disable setting by toggling what it is you want to do. (so I write a script that detects if wifi is up and if wifi is enabled then disable or if wifi disabled enable)
now I use lessthan 1 second press with a left or right button settings
a greaterthan 1 second press with a left or right button setting
a greater than 2 second press with a left or right button setting
a geater than 4 second press with a left or right button setting
so with single buttton press of 5 seconds I can launch up to 8 scripts (choice of 4 of them within a 2 second button press)
Ok, interesting stuff, but not exactly the experience I am looking for. I prefer to use a setting in uci to decide what action the button should perform. Where I am stuck is how update uci with the web cgi-bin api.
I changed the title of my question to better reflect what I am asking for help with.
The CGI files are all proprietary. What you could do is make your own page, and link it from the UI to extend it as you want, and make the corresponding scripts. The UI uses lighttpd so you wouldn’t have issues adding any kind of page.