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.

After I upgraded my notebook to ubuntu 12.04, I found that I can not save my power settings. Every time I set the screen brightness to 70%, it restored to 100% next time. I can't find a save button on the new power setting panel(I am sorry for I can not post a screenshot right now). Can anyone tell me how to save this setting? Thanks.

share|improve this question

6 Answers 6

up vote 14 down vote accepted

if you just wana change and save the screen brightness only, you can use xbacklight

     sudo apt-get install xbacklight

after installing, type command to set the screen brightness easily

     xbacklight -set `num`

the num is percentage of your screen brightness.

An easier way to set brightness and contrast

     sudo setpci -s `00:02.0` F4.B=`XX` 

to set brightness, 00:02.0 is your VGA device code.XX is hexadecimal form 00 to FF

use lspci command to find out your VGA device code.

     xgamma -gamma `X`

to set contrast,X from 0 to 1

share|improve this answer
    
Oh, currently I just want to save my screen brightness settings. Thanks, Teifi. :) –  Boris Jun 2 '12 at 16:25
1  
I can`t believe there is no GUI for this. Ubuntu should be linux for human beings. Thanks for the tip! –  umpirsky Nov 4 '12 at 19:15
    
Beware about using setpci for this. For details see askubuntu.com/questions/66751/… –  Stéphane Gourichon Nov 7 '13 at 6:00
  1. Check brightness levels by running this command as root:

    cat /sys/class/backlight/acpi_video0/max_brightness 
    

    (my laptop max brightness is 20)

  2. Set you screen brightness to minimum and check current level by evoking next command

    cat /sys/class/backlight/acpi_video0/brightness 
    

    (my laptop min brightness level is 0;)

  3. Edit /etc/rc.local and add before exit 0 the following line:

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

From now on this brightness level will be set every time you start your computer.

share|improve this answer

Personally I prefer starting with the brightness I had the last time I used my computer. Here is how I got that functionality:

First create a file to store your screen brightness between sessions:

cd /etc/init.d

sudo touch prev_brightness

sudo chmod o+w prev_brightness

Then create a script that stores your current screen brightness when shutting down into the file you created in the previous step:

sudo touch save_screen_brightness

sudo chmod +x save_screen_brightness

sudo gedit save_screen_brightness

Put this into the file you just opened:

#!/bin/sh

cat /sys/class/backlight/acpi_video0/brightness > /etc/init.d/prev_brightness

Now we need to make the script run every time we shut down or reboot the computer:

sudo ln -s /etc/init.d/save_screen_brightness /etc/rc0.d/K99save_screen_brightness

sudo ln -s /etc/init.d/save_screen_brightness /etc/rc6.d/K99save_screen_brightness

Finally we need to load the value we stored when starting the computer:

sudo gedit /etc/rc.local

Put this, before exit 0, into the file you just opened:

cat /etc/init.d/prev_brightness > /sys/class/backlight/acpi_video0/brightness

That's it!

share|improve this answer
    
Thanks, the solution worked like a charm although there is a slight pause before the previous settings are retained. –  Vesnog May 1 at 21:49
    
I want this answer to my question herePlease give me what is in my prev_backlight and save_screen_bightnessfinally. I tried your answer but not work.Thanks –  KasiyA Jun 14 at 8:11

Using Ubuntu 12.10 the solution Hevilath gave didn't work for me. No matter what I did with rc.local it wouldn't run.

I tried to add

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

before the exit 0 and it was not being called. I added some logging statements to /etc/rc.local and /etc/init.d/rc.local and nothing was being run at all.

This should be working because Upstart still runs the older System V scripts at the appropriate times for backwards compatibility.

So I read up on how to write an Upstart script from here.

I figured since System V is on its way out, I should learn about Upstart.

I wrote a simple script to set the brightness on my two monitors and it works without issue.

Check it out here.

All you have to do is copy the file into your /etc/init/ directory using sudo. It should just work unless the brightness value is being echo'ed to the wrong file in case it is a simple change.

Hope this helps

share|improve this answer
gksudo gedit /usr/local/bin/brightness_changer.py

Paste below code,

#!/usr/bin/python

import dbus
bus = dbus.SessionBus()
proxy = bus.get_object('org.gnome.SettingsDaemon',
                       '/org/gnome/SettingsDaemon/Power')
iface = dbus.Interface(proxy, dbus_interface='org.gnome.SettingsDaemon.Power.Screen')
iface.SetPercentage(70)

Save it. Then issue command,

sudo chmod 755 /usr/local/bin/brightness_changer.py

Open Startup Applications,

enter image description here

Click Add,

enter image description here

Give path as /usr/local/bin/brightness_changer.py in command and Save it.

Now whenever you login, brightness will be set to 70.

share|improve this answer
    
I think your program might be better suited for Bash, but I like you answer and I like Python. –  Sepero Nov 19 '12 at 12:57
    
@virpara: I was using your script and it used to work. But it doesn't work anymore with Gnome 3.10. I couldn't find org.gnome.SettingsDaemon.Power.Screen with dconf. Any ideas? –  Swarnendu Biswas Oct 20 '13 at 3:52

I'm using a HP all-in-one PC. And I cannot make xbacklight to be executed in rc.local, which the reason needed to be explored.

So I just put the

xbacklight -set 0

command into StartUp Applications and it helps reduce the screen brightness after login.

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.