This could probably be automated using either an OBS plugin (if you really want deep integration and not running another program) or a standalone program (written in whatever language you want) that listens for display changes and pokes OBS using its websocket API. The hooks are definitely there to update source configs.
Surely the main function of a capture program should be to capture video, no matter what, even if that means capturing too much / uninteresting sources some of the time?