You are not logged in.

#1 2016-05-16 06:26:12

ghorvath
Member
Registered: 2015-10-01
Posts: 161

Use laptop's wlan button to toggle wlan on/off

If your laptop's wlan button does not work as intended, you can do the following. Create a file in /usr/local/bin with the following content

## wlan
#!/bin/bash
WLAN_status=$(nmcli -t -f WIFI r)
case $1 in
  on)
    nmcli r wifi on
    ;;
  off)
    nmcli r wifi off
    ;;
  toggle)
    if [ $WLAN_status = "letiltva" ] ; then
      nmcli r wifi on
    else
      nmcli r wifi off
    fi
    ;;
  *)
    echo "Usage: $(basename $0) {on|off|toggle}"
    if [ $WLAN_status = "letiltva" ] ; then
      echo 'Current status: off'
    else
      echo "Current status: on"
    fi
    ;;
esac

Note, that this is for Hungarian localizations. The word 'letiltva' means 'disabled' in English. You should try to run

nmcli -t -f WIFI r

when wlan is on and when wlan is off to figure out what you should use.

Then add the following to your ~/.config/openbox/rc.xml file (I have it right after the mute button is defined).

    <keybind key="XF86WLAN">
      <action name="Execute">
        <command>wlan toggle</command>
      </action>
    </keybind>

After reconfiguring openbox from the menu, it should work.

Offline

Board footer

Powered by FluxBB