关于 if 语句中负数的帮助

关于 if 语句中负数的帮助

我正在编写一个脚本来使用笔记本电脑的内置加速计自动旋转屏幕。目前,以一种方式旋转笔记本电脑是可行的(并且当将其放回您通常使用笔记本电脑的方式时,它也会恢复正常)。我还需要进行旋转以将笔记本电脑转向另一个方向。这是我的代码:

#Read the accelerometer data
ACCEL=$(cut -d "," -f 2 /sys/devices/platform/lis3lv02d/position) 

if (($ACCEL > 700 ))
then 
   echo right
   xrandr --output LVDS --rotate right  # Rotate screen right
   exit
elif (($ACCEL < 300 ))
then
   echo normal
   xrandr --output LVDS --rotate normal  # Rotate screen normal
fi

如您所见,我添加了来自加速度计的正数代码。现在我需要对负数做同样的事情(-700 而不是 700,-300 而不是 300)。

相关内容