Niri does not allow xrandr to disable the monitors, I'd assume other compositors are also like that, sounds like a very out of scope thing to do through xwayland. If that assumption is correct, this won't work on most modern systems.
Also, the way it's done looks kind of hacky with constant enabling and disabling of displays. I'm sure xrandr does something to prevent useless commands like that from actually working, but I'd do something to not issue them in the first place.
My first thought is checking /sys/class/drm for whatever state you want, as in with something like this you can see which ports have a display on the other side currently:
# This is sh, by the way
for a in /sys/class/drm/*/status; do echo "$a: $(cat "$a")"; done
And you can listen to udev changes with something like this:
udevadm monitor --kernel --subsystem-match=drm
If an event is emitted, we check if the state of the port we are interested in changed and then do whatever we need.
Though, I'm also not sure if manually disabling the monitor is the correct way, maybe there is a better way of handling it in X11? I'd imagine it wanting to have at least one display enabled is configurable.
If the gun is treated like the hazard it is, I doubt it'd be the sole reason for such behaviour. Maybe he is just using it as an excuse when there are other issues he is not bringing up? But yeah, I can't possibly know all the intricacies of your family relationships and playing a remote family therapist is not the best thing to do. I hope you can find some common ground one day.
And sorry for throwing you into a "stereotypical American" bucket like that, it's a bit too easy to find such people nowadays.