I would like to switch an On Air sign at my work-from-home office when my webcam is on.
Detecting whether the webcam is on can easily be done via
cat /sys/module/uvcvideo/refcnt
if it outputs 0 no app is using the webcam, otherwise it is.
I already have a Wifi plug which can be switched using a HTTP GET request.
My only question is: Do I have to poll the output of the above command regularly, or can I get notified in some Bash, Python or PHP script from the kernel?
The idea would be to not generate unnessary system load by polling - or doesn't that matter?
I already tried inotifywait
but it does not seem to notice changes on the above pseudo file.
Based on jasonharpers answer I implemented it as a daemon that uses polling
https://github.com/amenk/OnAirDaemon