Thursday, 14 April 2016

Set Brightness permanently in Ubuntu

Sometimes the brightness controls in Ubuntu do not work properly. Sometimes Ubuntu reverts to its default maximum value every time it reboots. I have used xbacklight but no change was visible. There is a simple fix to the problem using the following steps

  • Locate the back light directory:  Simply type the command
     
    cd /sys/class/backlight/
     
    Next use ls command to list out all the graphics e.g. acpi_video0, radeon_bl0 etc..
  • Locate the brightness file: Enter  the directory, locate the "max_brightness" file and display its content using

    cat max_brightness

    This will display the maximum value max_val of brightness. The "brightness" file controls the screen brightness. Choose the value X you would like to set the brightness where X can be an integer between 0 to max_val. A small tip is to use a fraction of the max_val say 40% to help decide value of X.
    (You may have to do the same procedure on as many folders as there are in /sys/class/backlight/ i.e. in my case I had both acpi_video0 & radeon_bl0 so I had to do it twice for it to work)
  •  Set rc.local: Now that X is chosen simply edit "/etc/rc.local" file using the command
    sudo gedit /etc/rc.local

    This script is executed at the end of each multiuser runlevel. Before "exit 0" command type the following:

    echo X > /sys/class/backlight/<graphic_folder>/brightness
     
    (In my case, 
     echo 6 > /sys/class/backlight/acpi_video0/brightness 
     echo 51 > /sys/class/backlight/radeon_bl0/brightness 
     exit 0
    )
  • Reboot: Reboot your system and you will see that the settings would have taken effect

No comments:

Post a Comment