Changing laptop monitor brightness from the command line?
I'm generally a Gnome-user, but lately I've been playing around with some of the lighter-weight WMs (JWM and Fluxbox for the mostpart). I've got them configured the way I want, but I've run into one problem:
I cannot change the brightness of my laptop's monitor while using JWM nor Fluxbox.
My laptop is an HP Pavillion dv6000-series with an Nvidia graphics card and an AMD64 processor. I'm running Ubuntu 8.04_x86-64 with all the updates. Brightness controls work just fine in Gnome; I press Fn+F7/F8 and the display changes brightness and I get a little popup with a bar telling me how bright it is, so it's obviously not a hardware problem, or a blanket problem with my system: if Gnome can do it then I should be able to make Fluxbox do it too. (I've already figured out how to
Is there some kind of command-line function I can call that changes the brightness? I've tried /etc/acpi/video_brightness[up|down].sh, but those do nothing. When I evaluate $VIDEO_BRIGHTNESSUP or $VIDEO_BRIGHTNESSDOWN (the two variables that are used by those acpi scripts) I get null. I'm not sure if that's normal, but it doesn't affect Gnome's ability to change the brightness, so I don't *think* it's a problem.
In Fluxbox or JWM if I open up /sys/devices/virtual/backlight/acpi_vide
o0/brightness and edit it I can change the brightness. A value of 10 gives me full brightness, 5 gives me (what I assume to be) half, etc... I could write a script that just edits this file but there are 2 problems with this:
1- it feels like a horrible, kludgey way of doing it
2- it requires either chmodding the file to allow anyone to write to it, or running the script as root (neither of which appeals from a paranoid security perspective)
Also, I've noticed that the value in this file does not change when I change the brightness in Gnome. Changing the value manually changes the brightness when I'm using Gnome, but I can then change the brightness with my Fn+F# keys and the file remains unchanged.
I'm frankly at a loss at this point. Googling "fluxbox laptop brightness keys" (and related searches) has lead me nowhere that I haven't already been. Any advice you more experienced Linux-users can give me would be greatly appreciated. I really want to get this working.
Thanks a lot for your help!
I forgot to mention this before, but the keystrokes themselves are
being recognized: When I ran Xev and hit the keys and found out that the codes were 101 and 212 respectively. I've set up xmodmap to assign those keys the labels "SunVideoLowerBrightness" and "SunVideoRaiseBrightness". I can map these keystrokes to other functions, so all I need is the brightness up/down commands to map them to.
In the meantime I've written a simple little C program that reads and edits /sys/devices/virtual/backlight/acpi_vide
o0/brightness. I compiled it, put it in /usr/local/bin, and set the SUID flag. When I execute "$laptop-brightness [up|down]" it reports/raises/lowers the brightness appropriately. It's a bit of a hack, and I want to find the proper solution, but this will do for now.