Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On my Macbook Pro Ubuntu alsways boots with...

  • keyboard brightness at maximum illumination
  • screen brightness at maximum illumination

...both which I need almost never during normal usage.


Instead of directly manipulating configuration files, I'm thinking of a solution that would work like a script and set both brightness settings to a lower default. How might this be accomplished?

Unfortunately, I have no experience in scripting and would be glad if you can help me out here.

I've figured out what needs to be done to change both the screen brightness and the keyboard backlight. Can you help be to make this a script that is automatically run at login?

Change Keyboard backlight

echo 130 | sudo tee -a /sys/class/leds/smc::kbd_backlight/brightness

...where 255 is the maximum brightness and 0 is the lowest brightness.

Change screen brightness

echo 42311 | sudo tee /sys/class/backlight/gmux_backlight/brightness 

...where 4126 is the lowest brightness and 82311 the hightest.

I've noticed a another problem.. If I run echo 42311 | sudo tee /sys/class/backlight/gmux_backlight/brightness right after login, but then use the brightness buttons. The screen brightness settings first reset to maximum - and then the change get's applied. This is seems messed up...

share|improve this question
I'm running 12.04. – user24668 May 11 '12 at 13:22
up vote 4 down vote accepted

You can have root run the brightness commands upon reboot, by adding those commands to /etc/rc.local (gksudo gedit /etc/rc.local), so that it looks like:

#!/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 130 >> /sys/class/leds/smc::kbd_backlight/brightness
echo 42311 > /sys/class/backlight/gmux_backlight/brightness

exit 0

See also Brightness is reset to Maximum on every Restart

share|improve this answer
Great! This looks like it should work. I have to tell you that I currently run Ubuntu only in VM and have removed the native install on my MBP. So, I'll have to try this later still. But thank you very much already! – user24668 Nov 4 '12 at 8:18
This solution is not elegant for two reasons: 1) You need to enter your password after every login to run it 2) If you press the brightness keys for the display or keyboard after this script was applied, the brightness will be changed as if they the initial brightness were still maximum. – king_julien Jul 29 '13 at 15:30
I know that point 2) sounds a bit strange so I'll try to explain what happens. If the default brightness is always maximum after every boot, I will use this script to send echo 0 to turn off the keyboard backlight. Now, when I want to turn it on later and press the 'brightness increase' key, the brightness will not jump from 0 to a little, but from 0 to the maximum minus a little. – king_julien Jul 29 '13 at 15:33

Your Answer


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