Im afraid your script wouldn't help much, because connected but switched off displays are also detected via randr.
Im afraid your script wouldn't help much, because connected but switched off displays are also detected via randr.