Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My laptop comes with the option to toggle wireless with the Fn+F12 key, but unfortunately this key doesn't work. Now inspired by this question, I would like to write a script that can toggle the software state of the wireless, preferably without needing sudo.

share|improve this question

This basic script will do the job:

status=$(nmcli -t -f WIFI nm)
if [ $status = "enabled" ] ; then
    notify-send -i network-wireless-disconnected "Wireless" "Wireless disabled"
    nmcli nm wifi off
    notify-send -i network-wireless-none "Wireless" "Wireless enabled"
    nmcli nm wifi on
exit 0
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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