How can I adjust brightness settings when I am on battery? [duplicate]

I tried a lot of things to no avail to get gnome-control-center in 11.10 to handle this like gnome-power-manager used to.

I decideded to create a script and install it into pm-utils.

#!/bin/sh

ON_AC=##
ON_BATT=##

if ["$1" = "true"]; then

    echo $ON_BATT > /sys/class/backlight/<device directory>/brightness

fi

if ["$1" = "false"]; then

    echo $ON_AC > /sys/class/backlight/<device directory>/brightness

fi

exit 0

I kept it simple because (hopefully) it is a temporary solution. You must manually set your desired values in the two variables above. Use the slider in the "Screen" settings gui to set your desired brightness, then use cat /sys/class/backlight/<device directory>/brightness to retrieve the corresponding numerical value. Substitue the name of your device's directory for <device directory>. Do it once for AC brightness and once for battery brightness. Plug the name of your device directory and the brightness values into the script.

Save the script to a file in your home directory or wherever. I called it backlight. Make it executable with chmod a+x backlight and install it to pm-utils with sudo install backlight /usr/lib/pm-utils/power.d/

I'm not sure how it works resuming from suspend/hibernate because I don't use it, but it works well when booting with or without ac, as well as when hotplugging the charger.


To set your brightness to dim automatically on battery power go to your System Settings (search in your dash or go to your power/settings cog), then select Screen. It will give you a slider to turn battery dimming on and off.

As for changing brightness manually, if you don't have function keys to do so you may map key combinations to do so by going to System Settings > Keyboard > Shortcuts tab, and assigning brightness a new value.