1#!/bin/sh 2 3update_brightness() 4( 5 BRIGHTNESS=$(( `sysctl -n dev.isl.0.als` )) 6 if [ $BRIGHTNESS -lt 15 ]; then 7 BRIGHTNESS=15 8 fi 9 if [ $BRIGHTNESS -gt 100 ]; then 10 BRIGHTNESS=100 11 fi 12 return $BRIGHTNESS 13) 14 15update_brightness 16LAST=$? 17intel_backlight $LAST >/dev/null 18 19while sleep 1; do 20 update_brightness 21 NEW=$? 22 if [ $LAST -gt $NEW ]; then 23 DIFF=$(( $LAST - $NEW )) 24 if [ $DIFF -gt 4 ]; then 25 while [ $LAST -gt $NEW ]; do 26 LAST=$(( LAST - 2 )) 27 intel_backlight $LAST >/dev/null 28 sleep 0.01 29 done 30 fi 31 else 32 DIFF=$(( $NEW - $LAST )) 33 if [ $DIFF -gt 4 ]; then 34 while [ $LAST -lt $NEW ]; do 35 LAST=$(( LAST + 2 )) 36 intel_backlight $LAST >/dev/null 37 sleep 0.01 38 done 39 fi 40 fi 41done 42