我正在尝试创建脚本以自动重新连接我的蓝牙键盘,但是由于某些原因,即使if语句为false仍然运行命令来重新连接键盘
for (( ; ; ))
do
var=$(hcitool lq 50:E6:66:9C:BD:A5 | sed -n -e 's/^.*Link quality: //p')
num1 = 200
num2 = $var
if [ $num2 -lq $num1 ]
then
echo ${var}
echo "lower signal"
notify-send "Link Quality" "Low link quality, attempting to reconnect..."
bluetoothctl disconnect 50:E6:66:9C:BD:A5
echo "device has been reconnected"
fi
sleep 6s
done
hci命令恢复255(100%的信号),即使现在100%仍断开键盘连接
编辑:似乎我输入错误的变量应该是 num1 = 200 num2 = $ var
以及if:
if(( $num2 < $num1 ))
问题解决了