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.

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

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.