There's a blog post about a similar thing but without any extra hardware. It uses barrier and a few simple scripts. (monitor does have to support switching via dcc).
It's not perfect especially since the input switching for the display is quite slow but there's leg in hardware kvms too.
https://xpufx.com/posts/hundred-percent-software-kvm-switch/