Setting a HotKey to Toggle the WiFi On/Off (Alternative to the Fn+F2 switch)
Until this issue is fixed with newer updates, you may use "xbindkeys" tool to set a hotkey (can be a single key or a key-combination) of your choice to toggle the WiFi enabled/disabled.
This is how -
A. Create a Script to do it smartly :
First, we create a script (for ease of use, and so that we can toggle it on/off using the same hotkey) -
# Script to toggle the wireless blocked/unblocked
# index no. of phy interface
IFACE=`rfkill list all | grep phy | cut -c 1`
# WiFi block state 0=active, 1=blocked
BLOCKED=`rfkill list all | grep -iA1 phy | grep -ic soft.*yes`
if [ $BLOCKED -eq 1 ]; then
rfkill unblock $IFACE
rfkill block $IFACE
Copy-paste the contents of the above box in a text file and save this file in your Home directory with the name - "wifitoggle.sh
". Make sure the first line is (without double quotes) "#!/bin/bash
" and last one is "fi
Make the script executable by running the following command in a terminal -
chmod +x wifitoggle.sh
Run the following command to Create a symlink to this script in /bin directory -
sudo ln -s $HOME/wifitoggle.sh /bin
Now proceed to binding it with a hotkey as follows -
B. Bind the Script with a HotKey of your choice :
(a GUI frontend to xbindkeys - the program that captures and binds hotkeys with commands) -
sudo apt-get install xbindkeys-config
Create a default config file for it (else it would crash on key capture step) -
xbindkeys --defaults > ~/.xbindkeysrc
Run the program from terminal or "Alt+F2" (because it does not create a launcher in Unity dash) -
let the terminal running in the background..
In the GUI box that opens, 3 example shortcuts are already present. You may leave them.
Click on "New
" button at the bottom of the GUI.
In the right hand pane of the GUI, fill in a suitable name in the "Name
" field, e.g. "Toggle Wifi
Click on "Get Key
" button. This will open a tiny blank box doing nothing but waiting for your input.
Press the desired key (or key combination) that you want for toggling Wifi on/off. For example, "F3" key (as it remains mostly unused). The tiny box will disappear and the key will be recorded.
In the "Action
" field, type this -
Click on "Apply
" button and test the hotkey to see if it works as expected.
Click on "Save & Apply & Exit
" to save the new hotkey to the default file and exit.
From now on, as soon as you will press this key or the key-combination, the wifi will change its state from On to Off, or Off to On.
The Fn key doesn't seem to be noticed by any key capture program I could find (probably that's why it is considered "Hardware Switch"), so it's not possible to use it yet.
Once more, I'd request anyone who needs this workaround to submit a bug report against the problem, or add themselves to the "Affects Me" list, and point to this thread as a possible workaround.
The stronger it gets reported, the sooner we'll get it fixed, thus not requiring such crude workarounds.