Skip to content

Automate brightness level in Ubuntu 16.04 based on power source

Update(29-July-2017): Also tested on Dell Latitude-7480, and it works fine.

I personally did not find any app or settings which could easily do this, though this is not an app or gui, but its the simplest and easiest way at least for me.

I have successfully implemented this in Ubuntu 16.04 on my HP envy 13 ab0XX laptop.
Your mileage may vary based on your system.

Note : Change USERNAME to your username. File location is up to you bdw.
Create a file /home/USERNAME/ and paste the following in it:

# Adjust brightness of backlights based on power source
case $1 in
# On battery
# Dim screen backlight
expr `cat /sys/class/backlight/intel_backlight/max_brightness` / 2 > \

# On AC
# Don't Dim screen backlight
cat /sys/class/backlight/intel_backlight/max_brightness > \

return 0

It will dim the screen 50% on battery power which is fine for me.

Please note that /sys/class/backlight/intel_backlight/ could be something different in your system, like /sys/class/backlight/acpi_video0/. Check the dir /sys/class/backlight/.

Give execution permission to the script:

chmod 771

Create a udev rule, in /etc/udev/rules.d/99auto-backlight.rules with the following in it:

SUBSYSTEM=="power_supply", ATTR{online}=="0", RUN+="/home/USERNAME/ true"
SUBSYSTEM=="power_supply", ATTR{online}=="1", RUN+="/home/USERNAME/ false"

Remember to change the USERNAME.

To enable it at boot, add the following to /etc/rc.local before exit 0:

udevadm trigger -s power_supply

And there you have it. 🙂


Published inLinuxUbuntu

Leave a Reply


This site uses Akismet to reduce spam. Learn how your comment data is processed.

Notify of
Theme by Compete Themes. Enhanced for The Random Bits only. © The Random Bits 2018.