Screen brightness reset to minimum after every reboot

Ubuntu 11.10 doesn't save my brightness settings between sessions. Everytime I boot up, the brightness is always at zero, and I always have to set it back to my preferred setting (at maximum). How can I ensure that my brightness preference will persist after reboot?


Solution 1:

In the file /etc/rc.local add before line exit 0:

echo 5 > /sys/class/backlight/acpi_video0/brightness

Where 5 is the brightness level from 0 to 10

Solution 2:

Basically you need to run

echo X > /sys/class/backlight/acpi_videoY/brightness

during the boot process after the graphics drivers have loaded with appropriate X and Y. The other answers and comments explain how to find X and Y.


While the /etc/rc.local suggestion works, the most consistent way of doing this, in my opinion is the following:

Create a file, say customsetbootbrightness.conf, in /etc/init (avoid collisions with existing filenames in that directory) as root with the following contents:

description "Sets brightness after graphics device is loaded"

start on graphics-device-added
task
exec echo X > /sys/class/backlight/acpi_videoY/brightness

This way, the behaviour of the system will the same as systems without this particular quirk (of brightness being 0 at startup). In the /etc/rc.local method, there is usually a small period when the brightness remains 0.


Also, this should remove the necessity (in some systems) of having to sleep 2 before echo... - not checked though. (See http://xchamitha.blogspot.co.uk/2013/07/set-screen-brightness-when-booting.html or http://ubuntuforums.org/archive/index.php/t-2061712.html for example)

Solution 3:

You should probably check first:

ls /sys/class/backlight/ | grep 'acpi_video'

So you will get list of all possible displays and then you can experiment to find which is the display you want to modify. On one laptop, the screen was called "acpi_video0". Replace "acpi_video1" below with the actual screen name of your screen. On systems using the initsystem (e.g. 11.10) I must put

echo 5 > /sys/class/backlight/acpi_video1/brightness

in my /etc/rc.local file, whereas on systems using the newer upstart mechanism (e.g. 13.04) I must put this into /etc/init/screen_brightness.conf

start on runlevel [2345]
stop on runlevel [016]    

script
echo 5 > /sys/class/backlight/acpi_video1/brightness
end script

post-stop script
end script