解决Ubuntu18开机最大亮度问题

本文介绍了如何在Ubuntu系统中通过创建rc-local.service文件和rc.local脚本来实现开机自动调整屏幕亮度。具体步骤包括编辑rc-local.service文件,创建rc.local文件,添加相应代码以设置亮度,并赋予rc.local执行权限,最后启动和检查rc-local.service服务的状态。此方法适用于拥有nvidia或intel_backlight设备的用户,可以根据设备类型调整相应的亮度值。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

通过让ubuntu开机自动运行脚本解决亮度问题

1.建立rc-local.service文件

sudo gedit /etc/systemd/system/rc-local.service

2.将以下内容复制到rc-local.service文件中

[Unit]
Description=/etc/rc.local Compatibility
ConditionPathExists=/etc/rc.local
 
[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99
 
[Install]
WantedBy=multi-user.target

3.如果在/etc/下面没有rc.local文件,则创建

sudo gedit /etc/rc.local

4.复制以下代码到rc.local文件中
如果你/sys/class/backlight/文件夹下为nvidia_0则复制以下内容

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
echo 40 > /sys/class/backlight/nvidia_0/brightness
exit 0

nvidia最大亮度为100,选择你自己感觉合适的一个亮度数值。

如果你/sys/class/backlight/文件夹下为intel_backlight则复制以下内容

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
echo 1200 > /sys/class/backlight/nvidia_0/brightness
exit 0

5.给rc.local加上权限并启用服务

sudo chmod +x /etc/rc.local
sudo systemctl enable rc-local
sudo systemctl start rc-local.service
sudo systemctl status rc-local.service

只要不报错就行

重启后亮度变了就成功了。