2

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 that the button 'WLAN' was pressed. However I don't know how to assign that button to do its job.

edit

$ 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

2
  • Please edit your question to add the result of: rfkill list all Thanks.
    – chili555
    Dec 14 '14 at 22:31
  • @chili555 done.
    – Prastt
    Dec 16 '14 at 13:31
3

1) create a file called wifi.sh

2) copy these lines

#!/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 if you create wifi.sh in your desktop then its full path is /home/USERNAME/Desktop/wifi.sh - replace the USERNAME with your user name- ,

4) In System Settings> keyboard > shortcuts window

press on + sign to add a new keyboard shortcut and write the full path for wifi.sh file in second box for example /home/ahed/.config/wifi.sh then click on disable word then press your wireless key

Optional if not worked 5)

open Terminal ctrl + alt + t and install dconf-editor if not installed

$  sudo apt-get install dconf-editor  

run it

$  dconf-editor

go to /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0 and check 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 '14 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 '14 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 '18 at 22:11
0

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.