如何使用脚本切换无线

Ger*_*ger 3 scripts shortcut-keys wireless function-keys

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

Ger*_*ger 6

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

#!/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
Run Code Online (Sandbox Code Playgroud)