Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revisionBoth sides next revision
docs:guide-user:hardware:hardware.button [2021/08/31 06:39] – [procd buttons] Aesthetic changes freezeheatdocs:guide-user:hardware:hardware.button [2022/04/27 15:48] – [Attach functions to a push button] some1
Line 2: Line 2:
 There several ways for controlling buttons in OpenWrt. There several ways for controlling buttons in OpenWrt.
   * [[#procd_buttons| buttons using procd]]   * [[#procd_buttons| buttons using procd]]
-  * [[#Hotplug_Buttons|Hotplug buttons]], using the hotplug daemon or procd in compatibility mode (hotplug itself was phased out with r36003).+  * [[#Hotplug_Buttons|Hotplug buttons]], using the hotplug daemon or procd in compatibility mode (hotplug itself was phased out with r36003, circa 2013).
   * [[#HID_buttons|HID buttons]], using ///dev/input/event// with an application like triggerhappy.   * [[#HID_buttons|HID buttons]], using ///dev/input/event// with an application like triggerhappy.
  
Line 143: Line 143:
 uci set system.@button[-1].action="pressed" uci set system.@button[-1].action="pressed"
 uci set system.@button[-1].handler="uci set wireless.@wifi-device[0].disabled='1' && wifi" uci set system.@button[-1].handler="uci set wireless.@wifi-device[0].disabled='1' && wifi"
-uci commit system +uci commit system
 </code> </code>
  
Line 207: Line 207:
 } }
 EOF EOF
 +chmod u+x /usr/bin/wifionoff
 </code> </code>
  
Line 217: Line 218:
 STATEFILE="/tmp/wifionoff.state" STATEFILE="/tmp/wifionoff.state"
  
-if [ "${#}" -eq "1]; then+if [ "${#}" -eq 1 ]; then
     case "${1}" in     case "${1}" in
-        "up"|"on"STATE="off" ;; +        "up"|"on"GOAL="on" ;; 
-        "down"|"off"STATE="on" ;;+        "down"|"off"GOAL="off" ;;
     esac     esac
 else else
-    if [ -e "${STATEFILE}" ]; then +    if [ -e "${STATEFILE}" ]; then 
-        STATE="on"+ GOAL="on"
     else     else
-        source "${STATEFILE}"+        # if the statefile doesn't exist, turn wifi off 
 +        GOAL="off"
     fi     fi
 fi fi
-if [ -z "${STATE}" ]; then +  
-    STATE="on" +if [ "${GOAL}" = "off" ]; then
-fi +
- +
-if [ "${STATE}" = "on" ]; then+
     /sbin/wifi down     /sbin/wifi down
-    STATE="off"+    touch "${STATEFILE}"
 else else
     /sbin/wifi up     /sbin/wifi up
-    STATE="on"+    # file may not exist if we're given args 
 +    rm "${STATEFILE}2> /dev/null || true
 fi fi
- 
-echo "STATE=${STATE}" > "${STATEFILE}" 
 EOF EOF
 +chmod u+x /usr/bin/wifionoff
 </code> </code>
  
Line 251: Line 250:
 One way to find out your Wireless Network configuration name in LuCi is to navigate to the "Wireless Overview" page (Network > Wireless) and edit the wireless network configuration you need to toggle. For example, change temporarily the ESSID value and then click "SAVE" (and __NOT__ "SAVE & APPLY"). You will then see the button "UNSAVED CHANGES" in the upper right corner of the interface. Click on it and you should be able to find an entry such as "uci set wireless.cfg033579.ssid='My-Own-Wi-Fi-test'" where "cfg033579" stands for your configuration name that you need to change in the following script. One way to find out your Wireless Network configuration name in LuCi is to navigate to the "Wireless Overview" page (Network > Wireless) and edit the wireless network configuration you need to toggle. For example, change temporarily the ESSID value and then click "SAVE" (and __NOT__ "SAVE & APPLY"). You will then see the button "UNSAVED CHANGES" in the upper right corner of the interface. Click on it and you should be able to find an entry such as "uci set wireless.cfg033579.ssid='My-Own-Wi-Fi-test'" where "cfg033579" stands for your configuration name that you need to change in the following script.
  
-__/!\__ Warning ! Do not forget to allow the script execution with the command : **chmod u+x /usr/bin/wifinetonoff** 
 <code bash> <code bash>
 uci add system button uci add system button
Line 271: Line 269:
 } }
 EOF EOF
 +chmod u+x /usr/bin/wifinetonoff
 </code> </code>
  
Line 299: Line 298:
 uci commit system uci commit system
 </code> </code>
- 
 ==== WR1043ND ==== ==== WR1043ND ====
 If you decide to use the ''wifitoggle'' package, you will need to change a few things on the default configuration. If you decide to use the ''wifitoggle'' package, you will need to change a few things on the default configuration.
  • Last modified: 2022/09/25 20:08
  • by kirelagin