Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

http://ubuntuguide.net/how-to-save-screen-brightness-settings-in-ubuntu-12-04-laptop/

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 go on to find that I don't have any folder named

acpi_video0

but a folder called

intel_backlight

enter image description here

Every time I increase or decrease the brightness using the Brightness Control Keys the "brightness" and the "actual_brightness" values get updated.

Is there any method I could follow to set the brightness to a fixed value on everyboot and vary it as and when I need it using the Brightness Control Keys.

share|improve this question
    
I just tried this askubuntu.com/questions/145314/how-to-save-brightness-settings ... It doesn't work. –  Bhargav Jun 16 '12 at 10:14
    
possible duplicate of: How do I set default display brightness? –  Akronix May 10 at 10:38

14 Answers 14

up vote 37 down vote accepted

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

gksudo 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 the X by the desired brightness level.

share|improve this answer
1  
That worked like a charm.. Your Awesome :D –  Bhargav Jun 16 '12 at 10:41
3  
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
3  
X is the desired brightness level on a scale of 0-10 or 0-100? –  syedrakib Oct 14 '12 at 15:37
1  
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

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)
share|improve this answer
    
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 at 5:40
    
Unfortunately it breaks the brightness adjustment from the fn keys on 14.04. –  NoBugs Jun 29 at 2:20
    
works for me as well on 14.04 ... fn keys for brightess were not working also previously so ... –  Postadelmaga Jul 3 at 9:08
    
It's magic! Any my Fn brightness keys still work (Ubunu 14.04 LTS, Dell laptop) –  BurninLeo 20 hours ago

I wrote a small script - it saves last used value of brightness (stored in file BRIGHTNESS_CONTROL) to file (SAVEDFILE) on shutdown and restore it from file on next startup. If there is no such file - script set it do default value (DEFAULT_LEVEL). I placed this file in /etc/init.d/brightness:

#! /bin/sh
### BEGIN INIT INFO
# Provides:          brightness
# Required-Start:    $local_fs
# Required-Stop:     $local_fs
# Default-Start:     S
# Default-Stop:      0 6
# Short-Description: Save and restore brightness level between restarts.
# Description:       This script saves the brightness level between restarts.
#                    It is called from the boot, halt and reboot scripts.
### END INIT INFO

PATH=/sbin:/bin
SAVEDFILE=/var/lib/brightness-level
DEFAULT_LEVEL=4
BRIGHTNESS_CONTROL=/sys/class/backlight/acpi_video0/brightness

. /lib/init/vars.sh
. /lib/lsb/init-functions

do_status () {
    echo -n "Current brightness level is `cat $BRIGHTNESS_CONTROL`"

    if [ -f $SAVEDFILE ] ; then
        echo ", saved value is `cat $SAVEDFILE`."
        return 0
    else
        echo ", there is no saved value."
        return 4
    fi
}

case "$1" in
  start|"")
    [ "$VERBOSE" = no ] || log_action_begin_msg "Initializing brightness level"
    # Restore brightness level
    if [ ! -f "$SAVEDFILE" ]
    then
        echo "$DEFAULT_LEVEL" > "$SAVEDFILE"
    fi
    cat "$SAVEDFILE" > "$BRIGHTNESS_CONTROL"
    ES=$?

    [ "$VERBOSE" = no ] || log_action_end_msg $ES
    ;;
  stop)
    # Save brightness level
    [ "$VERBOSE" = no ] || log_action_begin_msg "Saving brightness level"
    cat "$BRIGHTNESS_CONTROL" > "$SAVEDFILE"
    ES=$?
    [ "$VERBOSE" = no ] || log_action_end_msg $ES
    ;;
  status)
    do_status
    exit 0
    ;;
  restart|reload|force-reload)
    echo "Error: argument '$1' not supported" >&2
    exit 3
    ;;
  *)
    echo "Usage: brightness start|stop" >&2
    exit 3
    ;;
esac

:

This file is based on /etc/init.d/urandom. You can customize the BRIGHTNESS_CONTROL and DEFAULT_LEVEL for your needs. You can test it from console after running sudo chmod +x /etc/init.d/brightness

  • /etc/init.d/brightness status (show current brightness level and saved in file value)
  • /etc/init.d/brightness start (set saved level from file)
  • /etc/init.d/brightness stop (save current level to file)

For normal operation of the script you need to create symlinks for 0 (shutdown), 6 and S (startup) runlevels.

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

I hope my script will help somebody.

share|improve this answer
2  
I reported a bug about including such initscript to default Ubuntu installation - bugs.launchpad.net/bugs/1270579. –  N0rbert Jan 19 at 13:41

When I use this:

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

then I modified the code in /etc/rc.local

$ gksudo gedit /etc/rc.local

------- BEGIN 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

------- END FILE -----------------------------

That worked for me.

share|improve this answer
1  
I don't get it, what would that do? It's already maximum by default. –  JMCF125 Aug 29 '13 at 22:49

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 this file "actual_brightness" in the intel_backlight folder will help. and the other wont.

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

so try this >>>

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

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer

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
share|improve this answer
    
And how does this fix the 'reset on reboot' issue in the question? –  gertvdijk Oct 16 '13 at 0:55
    
this adjust the brightness just for current session. if you restart then the brightness is reset. –  Sudeep Acharya Feb 3 at 18:47
    
Not if you add it to startup applications. And yes this is a work-around, not a full resolution. –  Brandex Feb 5 at 19:23

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
share|improve this answer
    
This worked great for me. All I needed was the /sys/class/backlight/acpi_video0/brightness line. –  bmaupin Nov 15 '13 at 16:44

Easiest way:

  1. Open a terminal window.

  2. Type in the following commands then hit Enter after each.

sudo apt-get install xbacklight

  1. Open the Startup Applications Preferences menu.

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

Name: Brightness Command: xbacklight -set 60

  1. Replace 60 with whatever brightness level you prefer.

Source: Set Startup Display Brightness

share|improve this answer

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!!

share|improve this answer

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.

share|improve this answer

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),
share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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