我想在电池电量不足时降低屏幕亮度。电源设置里没有这样的选项。或者,我可以将系统设置为在这种情况下关闭,但这是不希望的。是否有任何类型的脚本或 bash 命令可以用来在电池电量不足时设置较低的屏幕亮度?
答案1
sudo apt-get install xbacklight
并尝试一下
#!/bin/bash
lowBatLevel=25 #battery percent considered low
desiredBrightness=25 #brightness level to lower to ( 0 to 100 )
batLevel=`upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep percentage | awk '{print $2}' | sed 's/.$//'`
curBrightness=`xbacklight -get`
if [ $curBrightness -gt $desiredBrightness ] && [ $batLevel -le $lowBatLevel ] ; then #change 25 to your desired battery %
xbacklight -set $desiredBrightness
fi
我不在linux机器上,所以我没有测试过,如果有任何错误请告诉我