Set Acer laptop brightness on Ubuntu at boot

As I use my laptop continuously for hours, I set the brightness very low so that my eyes don’t hurt. My laptop is Acer Aspire 5738z and I had to struggle a bit to figure out how to set and control the brightness level at boot-up to avoid doing it manually. Here’s the whole procedure on tested Ubuntu 12.04:

First add the following in your /etc/default/grub file: acpi_osi=Linux in GRUB_CMDLINE_LINUX_DEFAULT line. For example, mine is:

GRUB_CMDLINE_LINUX_DEFAULT="quiet nosplash acpi_osi=Linux i8042.nomux"

Update GRUB for the change to take effect

$ sudo update-grub2

This will enable you to use the brightness keys in keyboard which in case of some Acer models doesn’t work just after installing Ubuntu. Now you need to know which Graphics Controller you are using. To check, run

$ sudo lspci|grep -i graphics
00:02.0 VGA compatible controller: Intel Corporation Mobile 4 Series Chipset Integrated Graphics Controller (rev 07)
00:02.1 Display controller: Intel Corporation Mobile 4 Series Chipset Integrated Graphics Controller (rev 07)

In my case it is the first one. If you are not sure run the following commands:

$ sudo setpci -s 00:02.0 F4.B=45
//where 00:02.0 is your controller ID from the above command
$ sudo setpci -s 00:02.1 F4.B=45

and check after running which one your brightness changes. Here I am setting the brightness level to 45 (which is also the value I use regularly). You can test with 30 to make sure the change in brightness is easily detectable.

To check in which file the brightness value is set just run the same command as a non root user. An error is thrown which shows that you do not have permission to modify the file:

$ sudo setpci -s 00:02.0 F4.B=45
pcilib: Cannot open /sys/bus/pci/devices/0000:00:02.0/config

A hexdump of the file shows something like:

$ sudo hexdump /sys/bus/pci/devices/0000:00:02.0/config
0000000 8086 2a42 0407 0090 0007 0300 0000 0080
0000010 0004 f400 0000 0000 000c d000 0000 0000
0000020 1801 0000 0000 0000 0000 0000 1025 0205
0000030 0000 0000 0090 0000 0000 0000 010b 0000
0000040 0000 0000 0048 0000 0009 110a 6488 1c00
0000050 8001 0370 0019 0000 0000 0000 0000 bc00
0000060 0000 0000 0000 0002 0000 0000 0000 0000
0000070 0000 0000 0000 0000 0000 0000 0000 0000
*
0000090 d005 0001 300c fee0 4189 0000 0000 0000
00000a0 0000 0000 0009 2006 0000 0000 0000 0000
00000b0 0000 0000 0000 0000 0000 0000 0000 0000
00000c0 0000 0000 0000 0000 0000 0000 0140 0000
00000d0 0001 0023 0000 0000 0000 0000 0034 0000
00000e0 0000 0000 0000 0000 8000 1a00 2041 0000
00000f0 1c0d 0734 0045 0000 0fa0 0007 0020 bbb7
0000100

As you can see, the sixth byte from 00000f0 is set to 45.

To run this at startup as root, add the command (e.g. setpci -s 00:02.0 F4.B=45) in your rc.local file and enable it. To avoid touching rc.local I have added it in the /etc/init/setvtrgb.conf file as the last line. Check this post of mine for a way to use a script using sudo, add it as a Startup Application and execute without any password if you are using ext4.

2 thoughts on “Set Acer laptop brightness on Ubuntu at boot”

Leave a Reply

Your email address will not be published. Required fields are marked *