Skip to content

Instantly share code, notes, and snippets.

@seidler2547
Created April 12, 2013 20:03
Show Gist options
  • Save seidler2547/5374700 to your computer and use it in GitHub Desktop.
Save seidler2547/5374700 to your computer and use it in GitHub Desktop.
Automatic brightness script for use with ACPI Ambient Light sensor and xbrightness. Other sources of ambient brightness are also possible of course.
#!/bin/bash
ODB=$(xbacklight -get)
while :
do
BR=`cat /sys/class/als/acpi_als0/illuminance`
echo -n $BR
[ $BR -lt 8 ] && BR=0
DB=`echo "l($BR+1)*l($BR+1)" | bc -l`
echo " - $DB"
[ $DB != $ODB ] && xbacklight -steps `echo "sqrt(($DB-$ODB)^2)*2+1" | bc | cut -d. -f1` -time `echo "sqrt(($DB-$ODB)^2)*20" | bc | cut -d. -f1` -set $DB%
sleep 0.5
ODB=$DB
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment