#! /usr/bin/env python2.7

from subprocess import call
from random import randint, random
from time import sleep

previ = 0
en = False

while True:

    if en == False:
        en = True
        i = randint(1, 3)
    else:
        while i == previ:
            i = randint(1, 3)

    if i == 1:
        call(["screenbrightness", "1"])
    elif i == 2:
        call(["screenbrightness", "0.5"])
    else:
        call(["screenbrightness", "0"])

    previ = i

    sleep(random())
