haimgel / display-switch

Turn a $30 USB switch into a full-featured multi-monitor KVM switch
https://haim.dev/posts/2020-07-28-dual-monitor-kvm/
MIT License
2.82k stars 110 forks source link

Switch on system (Application) boot #122

Open kirtangl opened 10 months ago

kirtangl commented 10 months ago

Hi mate,

I have been using this for a little while now, I have my work laptop connected to three monitors from a dock via HDMI(2) and my desktop via DisplayPort. As you can imagine, I was not interested in paying $1500+ for a KVM capable of doing what I wanted, so this was a lifesaver.

But I have one single little change request, that would make it perfect. Two of the monitors I have do not have the ability to disable auto input switching, which becomes an issue when I reboot my desktop for any reason, they will switch back to my work laptop. There is no way for me to resolve this, without having to manually switch them once the desktop starts (Not easy given the button positions). Or, what I have been doing, log into my desktop (My main monitor does not auto switch) then wait for this app to load, and switch my KVM to my laptop and back again.

As you can imagine, that's a pain. I am not familiar with rust, so I was hoping you could add a feature, that will switch displays on boot. So as soon as the app loads, fire off the command to switch all monitors to the desktop PC. I am aware this would not be something everyone would want, so I think adding it to the settings ini would be the best way to handle it;

Something like

usb_device = "0000:1111"
on_usb_connect = "DisplayPort1"
on_usb_disconnect = "Hdmi2"

Becomes

usb_device = "0000:1111"
on_load = "DisplayPort1"
on_usb_connect = "DisplayPort1"
on_usb_disconnect = "Hdmi2"

And obviously you could have the same tag per monitor etc. Thanks again mate for the fantastic work.

haimgel commented 8 months ago

Hello, The additional parameter seems unnecessary to me, at least if display-switch is working as intended. When the app starts up, it queries the connected monitors and connected USB devices, and will switch to on_usb_connect input if the specified USB device is found to be connected.

It does not switch away (e.g. to on_usb_disconnect) input when the specified USB device is not found on startup, but I don't think that's your use case, is it?