我的亮度设置有问题。当我将亮度降低到 1 并重新启动计算机时,它会重置为最大亮度值。我尝试调整它并再次将其降低到 1。为什么设置不保存最后的亮度设置?我如何通过编程保存当前值并在重新启动后恢复它?
我也尝试添加echo 0 > /sys/class/backlight/intel_backlight/brightness
文件/etc/rc.local
,但重启后它又重置为最大值。
我的笔记本电脑型号是Vaio SVF1521DCXW
。
答案1
acpi_video0
我在这个位置有另一个文件夹/sys/class/背光/
exit 0
我在gksu gedit /etc/rc.local
文件末尾但之前添加了以下命令:
echo 0 > /sys/class/backlight/intel_backlight/brightness
echo 0 > /sys/class/backlight/acpi_video0/brightness
它对我有用。现在我想获取当前亮度并将其保存到文件中,以便在下次重启时恢复它。
如何在下次重启后恢复上次调整的亮度负载?
步骤1:检查亮度级别
将亮度设置为最大限度并通过以下命令检查当前级别:
cat /sys/class/backlight/acpi_video0/max_brightness
(我的笔记本电脑最大亮度是100:)
现在将亮度设置为最低限度并通过调用下一个命令来检查当前级别:
cat /sys/class/backlight/acpi_video0/brightness
(我的笔记本电脑最低亮度级别是0:)
第2步:创建一个文件来存储当前亮度:
sudo touch /etc/init.d/prev_brightness
sudo chmod o+w /etc/init.d/prev_brightness
步骤3:创建一个脚本,将关机时的当前亮度(文件)存储到您在上一步中创建的save_screen_brightness
文件中:prev_brightness
sudo touch /etc/init.d/save_current_brightness
sudo chmod +x /etc/init.d/save_screen_brightness
使用您最喜欢的编辑器应用程序打开该save_screen_brightness
文件:
gksu gedit /etc/init.d/save_screen_brightness
并将此脚本放入其中:
#!/bin/sh
cat /sys/class/backlight/acpi_video0/brightness > /etc/init.d/prev_brightness
保存并进入下一步;)
步骤4:每次关闭或重新启动计算机时都运行脚本:
sudo ln -s /etc/init.d/save_current_brightness /etc/rc0.d/K99save_screen_brightness
## Shuttingdown ^^
sudo ln -s /etc/init.d/save_current_brightness /etc/rc6.d/K99save_screen_brightness
## Rebooting ^^
步骤5:加载我们在启动计算机时存储的值:
exit 0
在文件末尾和之前添加以下行/etc/rc.local
:
cat /etc/init.d/prev_brightness > /sys/class/backlight/acpi_video0/brightness
就是这样 ;)
答案2
在 Sony Vaio E15136CN(以及大多数配备 AMD 显卡的机型)上,acpi_video0 不存在。相反,radeon_bl0
在 中有 。因此,要添加到文件/sys/class/backlight
中的语句是rc.local
echo 60 > /sys/class/backlight/radeon_bl0/brightness
将 60 替换为您合适的任何值。我的亮度范围是 0 到 255(您可以在 中查看您的最大亮度/sys/class/backlight/radeon_bl0/max_brightness
),所以 60 适合我。
我遇到的所有答案都没有提到 AMD Radeon 显卡。所以我想我可以添加一个与之相关的答案。此外,Stéphane Gourichon 的回答如何设置默认显示亮度?不适用于 Sony Vaio E15136CN。简而言之,这些是要执行的步骤:
步骤1:
sudo nano /etc/rc.local
第2步:
echo 60 > /sys/class/backlight/radeon_bl0/brightness
步骤3:
重新启动系统。
答案3
制作如下文件fixMaxBrightness.sh
将所有这些行复制到它,使其可执行,chmod +x fixMaxBrightness.sh
然后通过此命令运行它,sudo ./fixMaxBrightness.sh
重新启动系统。
#!/bin/bash
#this script are going to get last change screen Brightness
#and put it in /.FixBritness
#this folder is in home directory that the following line make it
mkdir $HOME/.FixBritness
cd $HOME/.FixBritness
#make two another script that put current brightness in "currntBritness" file,
#and it must run when system is going down
cat > getBritness.sh <<_EOF_
#!/bin/bash
cat /sys/class/backlight/acpi_video0/actual_brightness > $HOME/.FixBritness/currntBritness
exit 0
_EOF_
#to get last brightness that saved in "currntBritness" file
#and put it in system brightness file
cat > putLastBritness.sh <<_EOF_
#!/bin/bash
cat $HOME/.FixBritness/currntBritness > /sys/class/backlight/acpi_video0/brightness
exit 0
_EOF_
# create currntBritness file and put zero to defult value
touch currntBritness
echo 0 > currntBritness
chmod 755 getBritness.sh
chmod 755 putLastBritness.sh
#put in /etc/init.d/ because these file will use in /etc/rc1 through rc6
mv getBritness.sh /etc/init.d/
mv putLastBritness.sh /etc/init.d/
#make a symbolic link to getBritness.sh that get brightness when:
#shutting down
ln -s /etc/init.d/getBritness.sh /etc/rc0.d/S11getBritness.sh
#and restart
ln -s /etc/init.d/getBritness.sh /etc/rc6.d/S11getBritness.sh
#symlink to put last brightness when system start.
ln -s /etc/init.d/putLastBritness.sh /etc/rc1.d/S66putLastBritness.sh
ln -s /etc/init.d/putLastBritness.sh /etc/rc2.d/S66putLastBritness.sh
ln -s /etc/init.d/putLastBritness.sh /etc/rc3.d/S66putLastBritness.sh
exit 0