Skip to content

Instantly share code, notes, and snippets.

@michaelkl
Created November 12, 2016 12:00
Show Gist options
  • Save michaelkl/111bcd8a6722172da84ee6aaf0fc2f1b to your computer and use it in GitHub Desktop.
Save michaelkl/111bcd8a6722172da84ee6aaf0fc2f1b to your computer and use it in GitHub Desktop.
screen brightness auto ajustment according to lighting (detected by webcam)
#!/bin/bash
TMPFILE=`mktemp /tmp/tmp.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.jpg`
fswebcam --jpeg 95 $TMPFILE
AVG=`convert $TMPFILE -format "%[mean]" info:`
BRIGHT=`echo $AVG | awk '{print int($1/65535*100+30)}'`
xbacklight -set $BRIGHT -time 2000
rm -rf $TMPFILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment