Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

1 Answer 1

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.