138

The brightness of my laptop is reset to max on every restart. I tried the solution provided at this website but had no luck.

This command

cat /sys/class/backlight/acpi_video0/max_brightness

Returns

cat: /sys/class/backlight/acpi_video0/max_brightness: No such file or directory

Then I found that I don't have a folder named acpi_video0, but a folder called intel_backlight:

screenshot of /sys/class/backlight/intel_backlight in Nautilus

Every time I increase or decrease the brightness using the brightness control keys, the values in brightness and actual_brightness get updated.

Is there any method I could follow to set the brightness to a fixed value on every boot and vary it as and when I need it using the brightness control keys?

20 Answers 20

112

You could try adding a line to /etc/rc.local that will set the desired brightness level. To edit the file, run

sudo -H gedit /etc/rc.local

and add the following

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

so that the end result looks like this

#!/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 X > /sys/class/backlight/intel_backlight/brightness

exit 0

Substitute X by the desired brightness level.

In case /etc/rc.local doesn't exist, as is the case with new Ubuntu releases, you'll need to create it, and make eecutable with the following commands:

printf '%s\n' '#!/bin/bash' 'exit 0' | sudo tee -a /etc/rc.local
sudo chmod +x /etc/rc.local

PS: Alternatively, there may be /sys/class/backlight/acpi_video0/brightness instead of the above. Brightness levels vary wildly, and may range from 0 to 10 or to 1000. To find the maximum value, try

cat /sys/class/backlight/acpi_video0/max_brightness
or
cat /sys/class/backlight/intel_backlight/max_brightness
  • 1
    That worked like a charm.. Your Awesome :D – b-ak Jun 16 '12 at 10:41
  • 5
    Probably. Different computers will have different entries in /sys/class/backlight/, and figuring out the right location, basically, solved the problem. – mikewhatever Jun 16 '12 at 13:28
  • 8
    X is the desired brightness level on a scale of 0-10 or 0-100? – Syed Rakib Al Hasan Oct 14 '12 at 15:37
  • 9
    Depends. Different models have different scales. I only had to deal with 0-7. Check the current level by running cat /sys/class/backlight/intel_backlight/brightness. It's a good idea to experiment with several values, if you aren't sure which one is right. – mikewhatever Oct 14 '12 at 23:33
  • 2
    Doesn't work for me in 12.04? – user24668 Jul 1 '13 at 18:11
25

I converted my small script for saving and restoring backlight (brightness) level to Ubuntu package. It is located in my PPA and named sysvinit-backlight.
It contains sysvinit init-script, placed in /etc/init.d/sysvinit-backlight.
It is compatible with Ubuntu 12.04 LTS and 14.04 LTS.

For newer versions of Ubuntu my PPA is not needed as they use builtin systemd-backlight service.

You can install my script with the following commands:

sudo add-apt-repository ppa:nrbrtx/sysvinit-backlight
sudo apt-get update
sudo apt-get install sysvinit-backlight

You can remove it by

sudo apt-get purge sysvinit-backlight

Please note: if you have installed the previous version of my script, please remove it by

sudo rm /etc/rc?.d/?25backlight /etc/init.d/brightness /etc/rc?.d/?25brightness

The script functionality is:

  • save backlight (brightness) levels of all video adapters and keyboard on reboot and shutdown (runlevel 0 and 6)
  • load backlight (brightness) levels for all video adapters and keyboard on boot (runlevels S, 1, 2, 3, 4 and 5)

The script options are:

  • sudo service sysvinit-backlight status (show current brightness levels and saved in files values)
  • sudo service sysvinit-backlight start (set saved levels from files)
  • sudo service sysvinit-backlight stop (save current levels to files)

You can contact me here or on launchpad.

  • 4
    I reported a bug about including such initscript to default Ubuntu installation - bugs.launchpad.net/bugs/1270579. – N0rbert Jan 19 '14 at 13:41
  • Works perfectly for my Dell laptop on Ubuntu 14.04. As the laptop has a on-chip graphics adapter plus another adapter (that is used by default), I just had to change /acpi_video0/ to /acpi_video1/. – BurninLeo Sep 19 '14 at 16:03
  • This script is practical. Worked for me too on my lenovo flex 2. I think it should also be included in default Ubuntu or Linux mint installs. – answerSeeker Oct 25 '15 at 3:16
  • This script no longer works in 16.04+ – answerSeeker Jun 21 '17 at 3:33
  • answerSeeker This script should not work in 16.04+, it is unneeded here. Use standard systemd-backlight@.service. – N0rbert Jun 24 '17 at 15:48
22

Easiest way:

  1. Open a terminal window.

  2. Type in the following command then hit Enter after it.

    sudo apt-get install xbacklight
    
  3. Open the Startup Applications Preferences menu.

  4. Click the Add button and add the following information:

    • Name: Brightness
    • Command: xbacklight -set 60
  5. Replace 60 with whatever brightness level you prefer.

Source: Set Startup Display Brightness

  • thank you, it works perfectly for me. Ubuntu 14.04 on Acer 5732Z – Sushiant Feb 2 '15 at 2:52
  • 1
    It doesn't work on ubuntu 16.10 – Searene Dec 5 '16 at 12:19
  • 1
    Does not work ubuntu 18.04 – Ahmad Sharif Sep 22 '18 at 5:57
13

Before try workarounds in rc.local, it is worth to try the following:

  • adding simple: quiet splash acpi_backlight=vendor to grub looks to be enough on my configuration.

    1. sudo gedit /etc/default/grub
    2. replace
      GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
      with
      GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nomodeset acpi_backlight=vendor"

    3. sudo update-grub and reboot.

worked on:

  • Ubuntu 12.04 LTS (Asus U31SD-XH51 )
  • Ubuntu 14.04 LTS (Dell 14z)
  • Ubuntu 14.04 LTS (Lenovo g500, remove nomodeset and it will work fine)
  • 2
    more details ubuntuka.com/ubuntu-command-line-tricks-set-1: sudo gedit /etc/default/grub and replace GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" to GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nomodeset acpi_backlight=vendor" – tbicr Jun 7 '14 at 5:40
  • Unfortunately it breaks the brightness adjustment from the fn keys on 14.04. – NoBugs Jun 29 '14 at 2:20
  • works for me as well on 14.04 ... fn keys for brightess were not working also previously so ... – Postadelmaga Jul 3 '14 at 9:08
  • This seemed to work fine - for one reboot (even the Fn keys on my Dell laptop worked). But after another reboot the Fn keys brightness did not affect the screen any more. And worse: The wakeup after standby (suspend to RAM) stopped working with a dark screen. – BurninLeo Sep 19 '14 at 15:37
6

I modified the code in /etc/rc.local like this:

Get maximum brightness:

$ cat /sys/class/backlight/intel_backlight/max_brightness
4882

Run gksudo gedit /etc/rc.local and edit the file:

#!/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 4882 > /sys/class/backlight/intel_backlight/brightness
exit 0

That worked for me.

  • 4
    I don't get it, what would that do? It's already maximum by default. – JMCF125 Aug 29 '13 at 22:49
  • You should use cat /sys/class/backlight/intel_backlight/brightness 168 instead. I use 168 because my eyes don't hurt at that brightness level – answerSeeker Sep 18 '15 at 16:15
5

Install xbacklight (sudo apt-get install xbacklight) and add

xbacklight -set x

(where 'x' = 0 to 100 desired brightness) to the startup applications via dashboard. For example:

xbacklight -set 50
  • 2
    And how does this fix the 'reset on reboot' issue in the question? – gertvdijk Oct 16 '13 at 0:55
  • 1
    this adjust the brightness just for current session. if you restart then the brightness is reset. – Sudeep Acharya Feb 3 '14 at 18:47
  • 2
    Not if you add it to startup applications. And yes this is a work-around, not a full resolution. – Brandex Feb 5 '14 at 19:23
4

The solutions offered here are somehow system-dependent.

A good design is to have one place that takes care of system-dependent details and provide a unified interface. It seems that currently the kernel does not offer such an easy interface through /sys. At X level, though, there is one : xbacklight.

A solution based on xbacklight is offered on How do I set default display brightness?, for 11.10 and up.

Plus, it should not have the problems reported on some areas (e.g. http://ubuntuguide.net/how-to-save-screen-brightness-settings-in-ubuntu-12-04-laptop ) that wrong brightness comes back in some situations.

3

How to debug backlighting:

https://wiki.ubuntu.com/Kernel/Debugging/Backlight

Unfortunately just adding acpi_backlight=vendor doesn't seem to save the default value for my 12.04 Lenovo G575.

2

My laptop is Compaq Presario CQ62 111TU, installed Ubuntu 12.04. The Following steps worked for me well.

  1. Adjust the screen brightness to your preferred level.
  2. Open Terminal and enter cat /sys/class/backlight/intel_backlight/actual_brightness and take down the value.
  3. Enter cat /sys/class/backlight/acpi_video0/actual_brightness and take down the value.
  4. Enter sudo gedit /etc/rc.local and add these before the last line exit 0 in gedit:

    echo ValueFromStep2 > /sys/class/backlight/intel_backlight/brightness
    echo ValueFromStep3 > /sys/class/backlight/acpi_video0/brightness
    

save and enjoy.

My settings are shown below

#!/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 478 > /sys/class/backlight/intel_backlight/brightness
echo 0 > /sys/class/backlight/acpi_video0/brightness

exit 0
  • This worked great for me. All I needed was the /sys/class/backlight/acpi_video0/brightness line. – bmaupin Nov 15 '13 at 16:44
2

I find N0rbert's solution to be the best one, as the script that he's provided allows to restore your previous brightness level on startup.

Although, there was a small modification that I had to introduce to his solution to make it work. Instead of creating symbolic links that he's mentioned, I've provided the following:

ln -s /etc/init.d/brightness /etc/rc0.d/S25backlight
ln -s /etc/init.d/brightness /etc/rc2.d/S25backlight
ln -s /etc/init.d/brightness /etc/rc6.d/S25backlight

Notice, that instead of rcS.d, I've added a symbolic link to rc2.d, which is a runlevel for "Graphical multi-user with networking" (see more). I believe that the reason why the former one doesn't work for me is Ubuntu overriding brightness level after it has been set up by the /etc/init.d/brightness script during S runlevel.

With that subtle change, restoring brightness level works like a charm, especially for Ubuntu 14.04 LTS on Lenovo ThinkPad L540.

2

I use a Sony Vaio S model and hybrid graphics. I disabled my ATI G card and so my intel HD 3000 serves as my only g card.

I found that setting the brightness value to the file actual_brightness in the intel_backlight folder will help. and the other wont.

for me my minimum brightness value is 236 and maximum is 4648, so you may set a value anywhere between this.

so try this:

echo 236 > /sys/class/backlight/intel_backlight/actual_brightness
1

No need to fall into scripting and coding.

Just follow these simple steps:

If screen brightness is stuck at maximum every startup, install xbacklight (sudo apt-get install xbacklight) and add "xbacklight -set x" (where 'x' = 0 to 100 desired brightness) to the startup applications via dashboard. For example, "xbacklight -set 50".

I have set brightness for my laptop to 30.

Source: https://help.ubuntu.com/community/AsusZenbookPrime [Search for word "brightness" and read related paragraphs on this source page.]

Enjoy!!

1

I added the following into /etc/rc.local, to manage the display brightness and keyboard backlit and it works perfectly

...
echo 30 | sudo tee /sys/class/backlight/acpi_video0/brightness
echo 3 | sudo tee /sys/devices/platform/applesmc.768/leds/smc::kbd_backlight/brightness

exit 0
1

Use this command to discover your current brightness level:

cat /sys/class/backlight/intel_backlight/brightness

Then, edit rc.local file using this command:

gksudo gedit /etc/rc.local

Add this line before exit 0 line:

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

If this don't solve the problem, can be that something in your system is overwriting the brightness level. Then, you can try add a sleep command to delay the execution of the previous command:

(sleep 10 && echo X > /sys/class/backlight/intel_backlight/brightness)

Source

0

It is well worth checking the max_brightness files for the absolute maximum values in /sys/class/backlight/intel_backlight and /sys/class/backlight/acpi_video0 directories to avoid setting unusable values.

My Dell Inspiron 5720 uses maximum values of 4882 and 100 respectively. I have set these to 2508 and 52 to prolong battery life. ACPI value in this case is equivalent to the percentage of the maximum brightness.

Editing rc.local works for me. I added comments to clarify how the values were determined. set required brightness with function keys and read values in brightness or actual_brightness files in each of the above Intel / ACPI directories.

0

For mint mate 17, you can set the default brightness by following steps:

  • sudo apt-get install dconf-tools
  • Applications -> System Tools -> dconf tools,
  • search for backlight, find and change following options:

    • brightness-ac
      brightness when use AC powser (charged),
    • brightness-dim-battery
      brightness when use battery (not charged),
0

all replies are helpful but didnt help me what i was trying to achieve. i wanted pre-defined levels of brightness for battery and ac power.

  1. use laptop mode tools from here laptop mode tools
  2. edit the conf file for brightness and replace [values] with the values you want. like "echo 1" for battery.wiki

works for me :)

0

Change default brightness level in Ubuntu 14. 04 LTS / Brightness is reset to Maximum on every Restart on Ubuntu 14.04 LTS

Here is what i found out.

In my case I had both the folders.

And when I changed the default brightness level, it took the change from the file in the folder acpi_video0. i.e. from the second line of code.

Here is the code that will be helpful for setting the default brightness level for Ubuntu 14.04 LTS.

#!/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.
#
#
#
#if you are changing the default brightness in Ubuntu 14.4 LTS
#the brightness under the folder acpi_video0 is important.
#Because brightness is set from that folder and not from intel_backlight
#(in case of my PC. It may very in others)
#That means you can omit the first echo line.
#However the command lines are given if any one has some problem and doesnot
#have the acpi_video0 folder
echo 1020 > /sys/class/backlight/intel_backlight/brightness
#Under the above given address the range of brightness is from 0 to 4648.
echo 3 > /sys/class/backlight/acpi_video0/brightness
#Under the above given address the range of brightness is from 0 to 7.
exit 0
0

This works on ubuntu 16.10

Create a file brightness.service in /lib/systemd/system with the following contents(Change 100 to whatever brightness you want, roughly it's between 0 ~ 1000).

[Unit]
Description=Lower default brightness

[Service]
ExecStart=/usr/bin/zsh -c "echo 100 > /sys/class/backlight/intel_backlight/brightness"

[Install]
WantedBy=multi-user.target

Enable it.

sudo systemctl enable brightness.

Restart. It will work.

0

This is yet another workaround

$ sudo dd if=/dev/tty of=/sys/class/backlight/intel_backlight/brightness
3000

Press Ctrl+D

less typing for fumble fingers...

protected by Community Dec 27 '16 at 12:27

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.