When ever I restart (or logout and login) my laptop the LCD display brightness is set to the maximum value. Even if I set the brightness settings in the power to the value I need, they won’t be in effect when I restart the machine.
Please note that rest of the blog article was edited on 5th of August 2012.
To solve this problem I wrote the following python script. First you need to add it to the startup applications list. The command to be given in the startup applications is βpython /<path>/<to>/<script>/setBrightness.py < Brightness level>β.
(If you don’t know how to add this to start-up applications please refer http://linuxandfriends.com/2011/06/01/how-to-add-startup-programs-in-gnome-3/ )
An example would be python /home/ishan/.setBrightness/setBrightness.py 20 . If you do not specify a brightness level, the script will change the brightness level according to the time of the day. If it’s between 7am and 8pm, the script will make the brightness be set to 75. If it’s between 8pm and 7am, the script will make the brightness be set to 20. You can edit these brightness levels by changing the variables day_level and night_level respectively.
A special thank should go to Sergio Aguilar for adding this neat functionality of brightness changing according to the time of the day and changing the brightness using parameter passing.
If you are using Gnome 3 or Unity –
Checkout the master branch from https://github.com/ishanthilina/setBrightness.
If you are using Gnome 2 –
Checkout the Gnome2 branch from https://github.com/ishanthilina/setBrightness.
please explain how to set the brightness value to all the way bright. I added your script to startup programs but don’t see where to change value from 0 thank you this started with upgrade to ubuntu 11.10 and now my startup is so dark I can hardly see to get to the setting to raise it.
The d-bus interfaces have been changed in Gnome 3 (also in Ubuntu 11.10). Please use this script :-).
http://ishans.info/attachments/article/65/setBrightness.py
(you can also get the script from https://github.com/ishanthilina/setBrightness )
Script to set brightness at Ubuntu startup
http://suhothayan.blogspot.com/2012/05/setting-brightness-at-ubuntu-startup.html
I just tried it and it adjusted the screen brightness but when I restarted the computer it went back to the way it was. Is there something else i need to do after I start up the script?
You need to add the script to the start up applications so that the script would be run every time you restart the computer.
is that “the startup applications list” means “rc.local” or something else?
cause i just added “python /usr/local/bin/setBrightness.py” into “rc.local”, but it didn’t work when i restarted my laptop.
Hi Eric,
In Gnome 3 you can easily achieve this using this article.
http://linuxandfriends.com/2011/06/01/how-to-add-startup-programs-in-gnome-3/
Gnome 2 has an entry called “Start up applications” under “Administration” or somewhere(I can’t recall the exact place).
Hope this helps π
Thanks buddy…:)
Works great !!
Love ubuntu n python !!!
Pingback: Mengatasi Bug Ubuntu 11.10 : Save Setting Brightness | Eko Suhartono
You should use a setting that is not 0 in your example – 0 sets it to the most dim setting. Other than that – great little script! Thanks, I had this issue on my new Folio 13.
Yes, 0 is the most dim and 100 is the brightest. I set the brightness to 0 cz that’s my personal preference. But I have clearly stated in the blog post and comments
“By default, the script will set the brightness to the minimum value. But if you want to change this, you can do that by editing the value 0 of the βvalueβ variable to any value between 0 to 100.”
So it’s up to you to decide the value you need π
What about unity.. my OS is Ubuntu 11.10.
And this OS has the brightness setting in system setting’s options, but there are some shortcut keys(Fn+F5/F6) can set brightness, too.
when I reboot it, the value of setting info shows about half of the brightness, but the display didn’t follow. still maximum brightness. but the shortcut keys can reduce it.
Hi Eric,
Really sorry the late reply. Yes, this script should support Ubuntu 11.10. Use the Gnome 3 version of the script.
My mistake..
Thanks.
Thanks a lot buddy!
It worked like a charm on Ubuntu 11.10!
Kudos to you!!!
The script works fine on my Lenovo Edge 15. Thank you from Germany !
Is there any posibility to enhance the script to the Bluetooth device ? On my 3 Lenovos the built in Bluetooth device is always on, at the startup. Similar to the full brightness.
I’d like to have Bluetooth disabled as default.
this works great on Mint 12 on my Lenovo Thinkpad x220t.
thanks a lot !!! π
if you have more of this cool terminal and scripting stuff, feel free, to “newsletter” me π
thx !!
Thank you !
Thank you very much.
Great π
Works fine for my hp folio 13 and Ubuntu 12.04 LTS.
Thanks a lot!
On line 44, the indentation of the second else statement prevented the script from working. I un-indented it and the script worked seemlessly.
Thanks!
Hi,
Thanks for pointing that out :-). Fixed it in the repository.
Hi,
This didn’t work for me, but the solution below worked like a charm and it is easier π
http://askubuntu.com/questions/151651/brightness-is-reset-to-maximum-on-every-restart
Hi,
First of all, I’m really sorry for keeping this comment under moderation for so long time. I totally forgot to approve the comment, only after I saw the comment by Maciek below I noticed that I haven’t approved this comment. Really sorry for that.
Anyways, can you point out what didn’t work out? Did you try manually running the script?
Also, if you take a look at the autoinstaller branch in the git repo you’ll find an easy to use version of the same script. It was there from a long time back, but I didn’t have the time to document about it.
Sorry for being so careless :D. Will document it asap :D.
That’s what I was looking for! Thank you!
Brightness on startUp for the HP Folio 13 with Ubuntu 12.04
-Install xdotool: sudo apt-get install xdotool
– create a “myfile.sh” with the content:
#!/bin/bash
myBrightness=2442;
currentBrightness=`cat /sys/class/backlight/intel_backlight/actual_brightness`;
count=$(( $currentBrightness – $myBrightness )) ;
while [ $count -gt 0 ]
do
xdotool key XF86MonBrightnessDown
let currentBrightness=`cat /sys/class/backlight/intel_backlight/actual_brightness`;
let count=$(( $currentBrightness – $myBrightness )) ;
done
– give it permisions: chmod 777 myfile.sh
– make it execute on the startup (startup applications>add)
– Note: use your own myBrightness value for custom brightness.
i am trying to change the brightness in ubuntu 11.10. please give the step by step procedure to change the brightness.and how to write a scripts in python.
Hi Shashikant,
You can use the content in the Gnome2 branch in the repo.
Details:
Save the file https://github.com/ishanthilina/setBrightness/blob/gnome2/src/setBrightness.py .
Then add the following entry to the startup programs.
python ////
Oh man, Thanks for the script
it worked like a charm in Ubuntu 12.10
I think there’s an easier way to add this script to start-up applications :
open the Startup Applications Preferences and then click Add then locate the script and finally click add . i’ve done it and it works
Great! I was googling for a solution for days and found this. It works perfectly on Ubuntu 13.04 beta/HP ProBook 4540s.
Thanks a lot.
Kapila
Thanks alot
worked perfectly on my Lenovo G580 using ubuntu 12.04_64
Pingback: How to make Unity remember brightness settings? | Some Ubuntu Questions and Answers
Pingback: Unix:How do I set default brightness after boot? – Unix Questions