如何使用脚本切换无线

我的笔记本电脑配有使用Fn + F12键切换无线的选项,但不幸的是这个键不起作用。 现在受到这个问题的启发,我想编写一个可以切换无线软件状态的脚本,最好不需要sudo。

这个基本脚本将完成这项工作:

#!/bin/bash status=$(nmcli -t -f WIFI nm) if [ $status = "enabled" ] ; then notify-send -i network-wireless-disconnected "Wireless" "Wireless disabled" nmcli nm wifi off else notify-send -i network-wireless-none "Wireless" "Wireless enabled" nmcli nm wifi on fi exit 0