I have a Monitor connected to my machine through HDMI.
Now if anyone were to switch off the Monitor, through either the Soft Buttons on it, or by removing it's Power Cord, I wish to be notified and run a Shell Script.
I tried many ways to identify when a monitor is switched on or off (It's always connected). The only technique that comes close is:
# ddccontrol -p
When the external monitor is connected, this returns all kinds of details about the monitor. I could write a script to parse the output for that. However this seems like a unreliable technique for un-supervised usage.
Is there any way through which I could obtain a Yes/No answer to whether the Monitor is Switched On/Off?
EDIT: It would be preferable if I can get a message on status change. Since this will be running continuously for days, I do not wish to poll for the status of the monitor. Instead in case it is switched off, I would like to be informed through a message.