How to set the laptop screen brightness programatically?

4

1

I'm currently migrating to openbox without gnome session. In unity i can use the vendor keys to set the screen brightness, but in openbox I'm on my own.

  • /sys/class/backlight/acpi_video0/brightness works fine, the problem is that I need sudo to set the brightness and that wouldn't work with keyboard mappings.
  • xbacklight -get/set doesn't do or output anything.
  • I don't really want to use xrandr --brightness.

Are there any other options or a way to fix the problems with xbacklight or acpi_video0 ?

user127199

Posted 2012-04-08T11:22:03.380

Reputation:

Answers

1

My solution was to add the following line to etc/rc.local:

chmod a+w /proc/acpi/video/VID/LCD/brightness

I don't know if permissions can also be changed in the /sys filesystem.

Jaap Eldering

Posted 2012-04-08T11:22:03.380

Reputation: 7 596

Doesn't feel that good to mess around with permissions there but the show must go on. Thanks eldering. – None – 2012-04-08T12:27:03.007

1/proc/acpi is obsolete, and recent kernel versions disable it by default. – user1686 – 2012-04-08T12:41:18.367

2

The command GNOME and Unity use is:

pkexec /usr/lib/gnome-settings-daemon/gsd-backlight-helper --set-brightness 5

It does not require a GNOME session to be running, just PolicyKit – which is almost always present in Ubuntu.


You can use ordinary sudo in key bindings; it can be configured to run certain commands without a password by editing the sudoers file. For example:

zls     ALL=(root) NOPASSWD: /usr/lib/gnome-settings-daemon/gsd-backlight-helper

or

zls     ALL=(root) NOPASSWD: /usr/local/bin/my-custom-brightness-script

user1686

Posted 2012-04-08T11:22:03.380

Reputation: 283 655