Here is how I do it:
1. First, find out which (if you have more than one) backlight interface(s) is your active interface. You can run this command to identify the interfaces:
Code:
for i in /sys/class/backlight/*; do echo $i; cat $i/brightness; cat $i/max_brightness; cat $i/actual_brightness; done
...in my case, I get:
2. To find out which one is the active one, echo a value between 0 and the second value above (max_brightness) to the brightness file:
Code:
echo 2000 | sudo tee /sys/class/backlight/intel_backlight/brightness
...you will probably need to change the value (2000) and the interface (intel_backlight) to suit your system. If you have more than one interface, try echoing appropriate values to all interfaces until one responds by changing the actual screen brightness. Some examples of commands are:
Code:
echo 4 | sudo tee /sys/class/backlight/acpi_video0/brightness
echo 32 | sudo tee /sys/class/backlight/acpi_video1/brightness
echo 64 | sudo tee /sys/class/backlight/nvidia/brightness
3. Once you have determined your active backlight interface and the correct brightness values that you want to use for "on battery" and "on a/c", create the following file:
Code:
gksu gedit /etc/pm/power.d/zzzbattery
...with the following content:
Code:
#!/bin/bash
case $1 in
true) #on battery
echo XX > /sys/class/backlight/INTERFACE/brightness
;;
false) #on ac
echo YY > /sys/class/backlight/INTERFACE/brightness
;;
esac
...where:
-
XX is the brightness value you want for when the system is on battery
-
YY is the brightness value you want for when the system is on a/c
-
INTERFACE is your active interface name
4. Save the file and make it executable:
Code:
sudo chmod +x /etc/pm/power.d/zzzbattery
...and test.
Caveats:
If you have no backlight interfaces or you are unable to change the brightness by manually manipulating the interfaces, then more work needs to be done to get an active backlight interface.
Bookmarks