在Linux上背光值每次重開機都會被設成最亮,這個問題一直很困擾人,查了一下可以透過修改
/sys/class/backlight/acpi_video*/brightness內容來調整背光設定。
底下寫了一個簡單的Script來修改這設定值:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| #!/bin/sh
if [ $# -ne 1 ]; then
echo "Usage: $0 <back light percent>"
echo "Example: $0 100: Set back light to maximum"
exit 1
fi
percent=$1
for acpi in /sys/class/backlight/acpi_video*
do
max=`cat ${acpi}/max_brightness`
val=$((max*percent/100))
sudo sed -i "/exit 0$/i echo $val > ${acpi}/brightness" /etc/rc.local
done
|
使用方式如下:
- ./set_backlight.sh 100:背光調成最亮
- ./set_backlight.sh 0:關掉背光
根據觀察在Notebook上會有兩組設定值,分別是
acpi_video0與
acpi_video1,acpi_video0是插上電源線會參考的數值,而acpi_video1是沒接電源線參考的數值,不過沒找到相關說明文件不是很確認這兩者的區別。