Ubuntu – Is it possible to setup a shortcut for enable/disable wifi

shortcut-keyswireless

Is it possible to setup a shortcut for enable/disable wifi?

Best Answer

This script will toggle the status, and show a message to confirm what's been done.

#!/bin/bash

if [ $(rfkill list wifi | grep "Soft blocked: yes" | wc -l) -gt 0 ] ; then
    rfkill unblock wifi
    zenity --info --text "Enabled wireless"
else
    rfkill block wifi
    zenity --info --text "Disabled wireless"
fi

To have the zenity prompts disappear, change them like so:

zenity --info --text "Enabled wireless" --timeout="5"
zenity --info --text "Disabled wireless" --timeout="5"

Or make notifications that appear in the corner of your screen. alt text

sudo apt-get install libnotify-bin

Replace the zenity lines with

notify-send -i network-wireless-full "Wireless enabled" "Your wireless adaptor has been enabled."
notify-send -i network-wireless-disconnected "Wireless disabled" "Your wireless adaptor has been disabled."