3

After messing around with GNOME desktop in Ubuntu 14.10 (I went back to Unity), my WLAN key doesn't work anymore. All the other keys (volume up/down, turn off screen, mute, etc) work except for the wireless toggle key.

If I go to keyboard shortcuts and modify any shortcut by typing Fn+F3 (that's my wireless toggle button) then it shows that the button 'WLAN' was pressed. However I don't know how to assign that button to do its job.

Here is the output of rfkill list:

0: acer-wireless: Wireless LAN
    Soft blocked: no
    Hard blocked: no
1: acer-bluetooth: Bluetooth
    Soft blocked: yes
    Hard blocked: no
2: phy0: Wireless LAN
    Soft blocked: no
    Hard blocked: no
0

3 Answers 3

3
  1. Create a file called wifi.sh.

  2. Copy these lines to it:

    #!/bin/sh
    
    if [ $(nmcli nm wifi | awk '/led/ {print}') = 'enabled'  ] ; then
        nmcli nm wifi off
        echo 'wifi off'
    else
        nmcli nm wifi on
        notify-send -i network-wireless-none "Wireless" "Wireless enabled"
        echo 'wifi on'
    fi
    
  3. Make it executable.

  4. Remember its full path so, for example, if you create wifi.sh in your Desktop then its full path is /home/USERNAME/Desktop/wifi.sh (replace USERNAME with your user's name).

  1. In System SettingsKeyboardShortcuts window, press on the + sign to add a new keyboard shortcut and write the full path for wifi.sh file in the second box (for example /home/ahed/.config/wifi.sh). Then click on the Disable word and then press your wireless key.

Optional if the above have not worked:

  1. Open Terminal using Ctrl+Alt+T and install dconf-editor if not installed:

    sudo apt-get install dconf-editor
    
  2. Run it:

    dconf-editor
    
  3. Go to /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0 and check the binding value. It should be XF86WLAN instead of WLAN (double click to change it).

2
  • I'll try this. What is the original directory for wifi.sh? It used to work before, but after messing with the desktop it stopped working. So I guess this was already implemented in some place.
    – Prastt
    Dec 16, 2014 at 13:39
  • original directory , it's up to you ,but i prefer home directory (~), or config directory (~/.config) which is hidden . right click on any file then click properties , you'll see it's path next to location
    – Ahed Eid
    Dec 16, 2014 at 18:20
1

Currently urfkill service provides the killswitch hotkey support system-wide. Simply apt-get install urfkill and the wifi toggle should work.

1
  • Works perfectly on a Samsung RF511 under KDE NEON / Ubuntu 16.04. Thanks.
    – nerdoc
    Jan 19, 2018 at 22:11
1

I found that the following worked for me

#!/bin/sh

if [ $(nmcli radio wifi) = 'enabled'  ] ; then
    nmcli radio wifi off
    notify-send -i network-wireless-none "Wireless" "Wireless disabled"
    echo 'wifi off'
else
    nmcli radio wifi on
    notify-send -i network-wireless-none "Wireless" "Wireless enabled"
    echo 'wifi on'
fi

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.