Created
September 7, 2012 16:54
-
-
Save sanchitgangwar/3667741 to your computer and use it in GitHub Desktop.
Auto adjust brightness with remaining battery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
while true | |
do | |
chargingState=$(grep "charging state:" /proc/acpi/battery/BAT0/state | awk '{print $3}') | |
batteryFull=$(grep "design capacity:" /proc/acpi/battery/BAT0/info | awk '{print $3}') | |
batteryRemaining=$(grep "remaining capacity:" /proc/acpi/battery/BAT0/state | awk '{print $3}') | |
batteryPercentage=$((batteryRemaining * 100/batteryFull)) | |
if [ $chargingState == "discharging" ] | |
then | |
if ((batteryPercentage > 30)) | |
then | |
xbacklight -set $batteryPercentage | |
else | |
xbacklight -set 0 | |
fi | |
fi | |
sleep 60 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment