5

What do I need to do to get my laptop screen backlight brightness controls to work? I currently have Ubuntu 13.04 and a Dell Studio 1558.

After reading these two links:

https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1007765
http://ubuntuforums.org/showthread.php?t=2061712

I attempted the following, I change the permissions (since I was having errors editing the files)

sudo chmod a+w /sys/class/backlight/intel_backlight/brightness

And then I overwrote the file with 1000 (appears max_brightness is 4882)

sudo echo 1000 > /sys/class/backlight/intel_backlight/brightness

And lo and behold, my screen dimmed.

I've tweaked it before, I'm not sure exactly how, and I don't know why I had to change the permissions on the file again, if I did it that way before.

How can I adjust brightness with the standard keys?

5

xbacklight

$ xbacklight +30% # increases brightness by 30 percent
$ xbacklight -30% # decreases brightness by 30 percent

dbus way

$ dbus-send --session --print-reply \
      --dest="org.gnome.SettingsDaemon" \
      /org/gnome/SettingsDaemon/Power \
      org.gnome.SettingsDaemon.Power.Screen.SetPercentage \
      uint32:<percentage>
Example

Set brightness to 30%:

$ dbus-send --session --print-reply \
      --dest="org.gnome.SettingsDaemon" \
      /org/gnome/SettingsDaemon/Power \
      org.gnome.SettingsDaemon.Power.Screen.SetPercentage \
      uint32:30 

Or
To decrease brightness by a step (~7)

$ dbus-send --session --print-reply \
      --dest="org.gnome.SettingsDaemon" \
      /org/gnome/SettingsDaemon/Power \
      org.gnome.SettingsDaemon.Power.Screen.StepDown

To increase brightness by a step (~7)

$ dbus-send --session --print-reply \
      --dest="org.gnome.SettingsDaemon" \
      /org/gnome/SettingsDaemon/Power \
      org.gnome.SettingsDaemon.Power.Screen.StepUp

If it says as follows your OS may be too old. Then use xdotool:

Error org.freedesktop.DBus.Error.UnknownMethod: 
Method "SetPercentage" with signature "u" on interface 
"org.gnome.SettingsDaemon.Power.Screen" doesn't exist

xdotool

  • Increase brightness:

    $ xdotool key XF86MonBrightnessUp
    
  • Decrease brightness:

    $ xdotool key XF86MonBrightnessDown
    
  • Your "dbus way" works only with Gnome (and also if you run gnome-settings-daemon independently, for example with plain window manager such as openbox). – Risto Salminen Jan 16 '14 at 11:40
  • Accepting because it's the only one :D – Aaron Hall Jan 26 '14 at 5:31
  • Does it work ?. – totti Jan 26 '14 at 5:38
  • 1
    The dbus way gives me this error: Error org.freedesktop.DBus.Error.UnknownMethod: No such method 'SetPercentage' – xuhdev Nov 28 '14 at 7:36
1

Well I actually didn't do what the accepted answer says. This is a function in my .bashrc:

bright () { sudo sh -c "echo $1 > /sys/class/backlight/intel_backlight/brightness " ; }

I use it like this -

Full brightness:

$ bright 4882

About one-tenth brightness:

$ bright 482

And because the function uses sudo, I have to type in my password, which is ok with me.

0

Here 2 alternative scripts.

Save it as brightness_change.sh and put it in a folder that is part of your $PATH environment variable. The usage is simple: brightness_change.sh up / brightness_change.sh down.

You can then assign the script to a keybinding, just take care to specify the full path to the command.

1. DBUS script ( for gnome )

I prefer the Dbus approach because :

  • you don't need special permission to change the brightness
  • the brightness changes done by script are reflected in the brightness applet

Here the script

#!/bin/bash
function up(){
    dbus-send --session --type="method_call"  --dest="org.gnome.SettingsDaemon" /org/gnome/SettingsDaemon/Power org.gnome.SettingsDaemon.Power.Screen.StepUp
}

function down(){    
    dbus-send --session --type="method_call" --dest="org.gnome.SettingsDaemon" "/org/gnome/SettingsDaemon/Power" "org.gnome.SettingsDaemon.Power.Screen.StepDown"
}

if [[ $1 = "up" ]]
then
     up
elif [[ $1 = "down" ]]
then        
    down
fi

2. Using the /sys/ files

Using this method requires either you change the permission of the destination file in /sys/ (every boot) either you can had the command to /etc/sudoers to require no passwords

I was not sure how to implement the first way so I have added this line to the /etc/sudoers ( where fra is my user )

fra ALL=(ALL) NOPASSWD:/home/fra/bin/bright_change.sh

Now you can call the command with sudo without you get prompted for password ( it for sure an hole in the security so take care of that )

#!/bin/bash
file="/sys/class/backlight/intel_backlight/brightness"
level=$(cat $file)
inc=100

if [ $level -lt "600" ]
then
    inc=50
fi

function up(){
    newlevel=$(($level+$inc))
    echo $newlevel
}

function down(){    
    newlevel=$(($level-$inc))

    if [ $newlevel -lt "10" ]
    then
        newlevel=1
    elif [ $newlevel -lt "100" ]
    then
        newlevel=10
    fi
    echo $newlevel
}


if [[ $1 = "up" ]]
then
     newlevel=$(up)
elif [[ $1 = "down" ]]
then        
    newlevel=$(down)
fi  


echo $newlevel
# echo $level

echo $newlevel > $file

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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