5

In Ubuntu 14.04 there is no option in the energy settings what to do when the battery is low. There is only a setting for action when critical.

I would like to automatically dim the brightness on my laptop when the battery reaches a low level.

Is there a hidden setting for this?

rubo77
  • 31,573
  • 49
  • 159
  • 281
  • I don't know if it fires an event on every battery percentage changed without polling but that is exactly what I would want to accomplish this task. – RobotHumans Jul 01 '14 at 07:30
  • Maybe there is a solution like suggested for how to [reduce Screen brightness in battery mode automatically](http://askubuntu.com/q/183335) – rubo77 Jul 02 '14 at 08:36
  • That does nothing for finding the battery change percent signal. Everything else is simple. – RobotHumans Jul 02 '14 at 08:44
  • The battery level can be read on the console with: [How to check battery status using terminal?](http://askubuntu.com/a/490713) `upower -i $(upower -e | grep BAT) | grep --color=never -E percentage|xargs|cut -d' ' -f2|sed s/%//` – rubo77 Jul 02 '14 at 09:07

1 Answers1

2

This script works for me for doing exactly this. The drawback is that it will continue to set the brightness level even after increasing it manually, when the battery is low, and it does not check if the ac adaptor has been connected.

/etc/acpi/events/battery_changed

event=battery.*
action=/etc/acpi/actions/dim_screen_on_low_battery.sh

/etc/acpi/actions/dim_screen_on_low_battery.sh

#!/bin/bash

BATTERY_LOC="/sys/class/power_supply/BAT0/"
VIDEO_LOC="/sys/class/backlight/acpi_video0/"

percent_left=$((100 * `cat /sys/class/power_supply/BAT0/charge_now` / `
                       cat /sys/class/power_supply/BAT0/charge_full`))
#echo "$percent_left% battery remaining"
if [ $percent_left -lt 20 ] # Adjust the battery limit.
# Adjust the dimmed brightness level.
then echo 50 > /sys/class/backlight/acpi_video0/brightness 
fi
Knotgrund
  • 46
  • 3