I want to use cron and this script (http://askubuntu.com/questions/23593/use-webcam-to-sense-lighting-condition-and-adjust-screen-brightness):
import opencv import opencv.highgui import time import commands def get_image(): image = opencv.highgui.cvQueryFrame(camera) return opencv.adaptors.Ipl2PIL(image) camera = opencv.highgui.cvCreateCameraCapture(-1) while 1: image = get_image() image.thumbnail((32, 24, )) image = tuple(ord(i) for i in image.tostring()) x = int((int((max(image) / 256.0) * 10) + 1) ** 0.5 / 3 * 10) cmd = ("sudo su -c 'echo " + str(x) + " > /sys/devices/virtual/backlight/acpi_video0/brightness'") status, output = commands.getstatusoutput(cmd) assert status is 0
crontab: /30*** sudo python /home/username/screen.py
However, there are two issues:
First, can the while-loop be terminated after 5 sec or so? Second, could anyone please try to improve the script so that lower brightness-levels can be set using the script? Maybe the way the 256 brightness-levels are mapped to the ones that can be set for the screen would need to be changed.