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.85k stars 112 forks source link

Monitor ids #33

Closed phit closed 3 years ago

phit commented 3 years ago

Heya, been waiting for the multi monitor support and just tried the new release. All my monitors are listed as Generic PnP Monitor in the Windows device manager. Not sure what you mean with monitor id in the readme, but here's the hardware id

e.g. image

I tried the config like this

usb_device = "046D:082D"

[monitor1]
monitor_id = "sam"
on_usb_disconnect = "0xfe"

[monitor2]
monitor_id = "del"
on_usb_connect = "DisplayPort1"
on_usb_disconnect = "DisplayPort2"

but according to the log "Display 'Generic PnP Monitor' is not configured to switch on USB disconnect", neither my dell or samsung monitor seem to be finding their config

full log https://gist.github.com/phit/b3486d2cd35513445d7bcd9858e17f62

thanks for any advice!

phit commented 3 years ago

mh I just found this https://www.eightforums.com/threads/tutorial-how-to-change-device-names-in-device-manager.15321/ maybe using that to change the name will work, I'll try tomorrow morning and report back

phit commented 3 years ago

that did not work, it seems to use the driver description and not the device name

grafik

haimgel commented 3 years ago

I think these are two separate problems:

  1. The app is not adaptive enough to deal with display names that are not unique.
  2. The app is not using the "true" display name on Windows when the "generic" display driver is in use.

I've pushed a quick commit to deal with problem 1 above: I added some logic to add a numeric index to the names if they are not unique, e.g. you'll get "Generic PnP monitor #1", "Generic PnP monitor #2", etc. Which is not great, but will allow you to target the right monitor with just "1" and "2" as the "monitor_id" in the config, if the index is stable.

I'll see what can be done about problem 2 later, will need to do some experimentation on Windows. Meanwhile, could you please run the following command from PowerShell:

Get-WmiObject -Query "Select * FROM WMIMonitorID" -Namespace root\wmi

(this would give an indication if Windows has any additional info about these monitors).

phit commented 3 years ago

Output: https://gist.github.com/phit/71549439133f4ba38687405f3dba67fd

The index appears to be stable, at least in the device manager, but I actually found some drivers for the older of the two, so one has a name now. However I only installed it on one of my PCs so far, I'll check in a couple hours on my other PC if your workaround works, I assume I'm not the only person that has never installed any display specific drivers.

Now I'm running into a bunch of other issues with the displays, but I'll make separate issues for that if its not the monitors DDC implementations fault (which it probably is).

B0rax commented 3 years ago

With this new commit it is still not working for me. From the log file:

08:06:56 [INFO] Display 'Generic PnP Monitor' is currently set to Hdmi1(0x11)
08:06:56 [INFO] Display 'Generic PnP Monitor' is currently set to DisplayPort1(0xf)
08:07:11 [DEBUG] (1) display_switch::app: Detected device change. Removed device: "05e3:0612"
08:07:11 [INFO] Monitored device is ("05e3:0612") is disconnected
08:07:11 [INFO] Display 'Generic PnP Monitor' is not configured to switch on USB disconnect
08:07:11 [INFO] Display 'Generic PnP Monitor' is not configured to switch on USB disconnect

My config file looks like this:

  usb_device = "05E3:0612"

[monitor1]
  monitor_id = 1
  on_usb_connect = "Hdmi1"
  on_usb_disconnect = "DisplayPort1"

[monitor2]
  monitor_id = 2
  on_usb_connect = "DisplayPort1"
  on_usb_disconnect = "Hdmi1"
haimgel commented 3 years ago

@B0rax yeah, there was a bug in "check for unique monitor names" logic. Please re-try, I've pushed a fix to Master.

B0rax commented 3 years ago

That worked! Thank you 👍