Tired of your backlight resetting every time you boot your laptop or set it to hibernate? Create a new file containing the following content in /usr/local/bin, and name the file check_backlight
#!/bin/bash
WAIT_TIME=3
LOOP_COUNTER=$\$$((60/$WAIT_TIME))
for i in `seq 1 $\$$LOOP_COUNTER`; do
DESIRED_BRIGHTNESS=22
BRIGHTNESS_COMMAND='/usr/bin/intel_backlight '
BRIGHTNESS_PERCENTAGE=`$\$$BRIGHTNESS_COMMAND | awk '{print $\$$(NF)}'`
BRIGHTNESS=$\$${BRIGHTNESS_PERCENTAGE%'%'}
if [ $\$$BRIGHTNESS -ne $\$$DESIRED_BRIGHTNESS ]; then
BRIGHTNESS_COMMAND+=$\$$DESIRED_BRIGHTNESS
eval $\$$BRIGHTNESS_COMMAND
fi
sleep $\$$WAIT_TIME
done
Now add the following line to /etc/crontab
* * * * * root /bin/bash /usr/local/bin/check_backlight
This entry in crontab will run the script /usr/local/bin/check_backlight every minute. The check_backlight script loops for 60 seconds, checking the backlight every WAIT_TIME seconds.
No comments:
Post a Comment