By Unknown

Maximizing battery life with laptop-mode-tools part 2

In my last post about laptop-mode-tools, we set the CPU governor setting. This time, we'll get laptop-mode-tools to automatically change the screen brightness depending on whether or not the laptop is plugged in.
First we need to find out where your brightness setting is stored. On my laptop, the setting is listed under /sys/class/backlight/acpi_video0/brightness but on other systems it could be listed under a different directory than acpi_video0, and could in fact be something like /proc/acpi/video/VID/LCD/brightness. A good way to find out where your setting is is to type this into a terminal:
cd /proc/acpi/video
Then hit the Tab key a couple times. It will either add the correct path, show a list of available paths, or do nothing and/or beep at you indicating you've come to a dead end. If the last thing happens to you, type:
cd /sys/class/backlight
Repeat the process. If you see both acpi_video0 and radeon0, I've found that it's usually under the former.

I'll use my system as the example. First, we set the brightness, using the function keys, to the desired setting for battery - usually the lowest you can tolerably use. Then, we find out the brightness setting:
cat /sys/class/backlight/acpi_video0/brightness
Note the value that it reports. Now, set your brightness to where you want it to be when the laptop is plugged into power. Repeat the same command. Now we're going to edit the file and set these values:
gksu scratch-text-editor /etc/laptop-mode/conf.d/lcd-brightness.conf
Enable brightness control by editing this section to read "1" instead of the default "0":
#
# Should laptop mode tools control LCD brightness?
#
CONTROL_BRIGHTNESS=1
Scroll down, and edit the end section to look something like this:
#
# Commands to execute to set the brightness on your LCD
#
BATT_BRIGHTNESS_COMMAND="echo 3"
LM_AC_BRIGHTNESS_COMMAND="echo 12"
NOLM_AC_BRIGHTNESS_COMMAND="echo 12"
BRIGHTNESS_OUTPUT="/sys/class/backlight/acpi_video0/brightness"

Replace 3 with your desired battery brightness, and 12 with the brightness setting you want while connected to power. Replace /sys/class/backlight/acpi_video0/brightness with the correct file for your system. Save the file, exit. Try unplugging and plugging your power cable and seeing if the brightness changes accordingly. If it does, we've succeeded!