Detect Ambient Darkness In The Room
17 Jul 2016A small bash script to detect if the room is dark. It may come handy for automating a variety of tasks.
e.g. when dark:
- shut down computer
- start a maintenance job
- stop music
or when not dark:
- start music
- bring up your dev environment (if you are that kind of person)
What it does:
- Takes a snapshot using webcam.
- Calculates average RGB value of the image.
- Compares it to the threshold for darkness.
I have used 0x212121 as threshold. You can customize it as per your taste and conditions.