Control monitor connection

Good day!
I have multimonitor connection. So when I boot up computer I control number of screens and send a message if some monitor is not connected.
But I want to report when monitor disconnected from system.
Is it possible to query state of screen?
I can search in Xorg.0.log for connection and disconnection, but maybe there is more elegant way?