some cleanup; add code to detect overall brightness and exit if all goes dark

not tested on a pi yet