Fix wireless soft-switch when running Debian on HP dv6

The HP dv6 laptop has touch switch to turn the wireless on & off.
When running Debian Wheezy on this laptop the wireless will turn off (blue -> orange), but doesn’t turn back on.  The status can also be viewed by using rfkill application (install from apt/Synaptic), using the command:

rfkill list

To get the light to change from orange to blue when the wireless is re-enabled we need a couple of scripts.
Firstly create the udev rule that will call a script when rfkill is triggered:
e.g.: sudo nano /etc/udev/rules.d/75-rfkill.rules
SUBSYSTEM==”rfkill”,ATT=”wlan”,ACTION==”change”,ATT=”1″, RUN+=”/usr/local/bin/fixwifi”
Next create the script that will turn on the wireless interface, and restart wlan0 to fix routes:
e.g.: sudo nano /usr/local/bin/fixwifi

# Turn the light blue
ifconfig wlan0 up
# Restart networking to get correct default gateway
ifdown wlan0; ifup wlan0

Make the script executable:
sudo chmod +x /usr/local/bin/fixwifi

Test it! Remember you must have rfkill installed and you can use “rfkill list” to view switch status.
Tested on Kernel 3.2.04-amd64.