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

Suddenly stopped working. How to debug? #101

Closed kcorey closed 8 months ago

kcorey commented 2 years ago

Hi All,

I have display-switch on my computer for a couple years now (Thanks haimgel!)

A week or two ago it just stopped working. I had upgraded to 12.4 a couple weeks prior.

You can see that I seemingly am starting display-switch as normal:

18:45:03 [INFO] Configuration loaded ("/Users/kcorey/Library/Preferences/display-switch.ini"): Configuration { usb_device: "0bda:0411", input_sources: InputSources { on_usb_connect: None, on_usb_disconnect: None }, monitor1: Some(PerMonitorConfiguration { monitor_id: "LG", input_sources: InputSources { on_usb_connect: Some(Hdmi1(0x11)), on_usb_disconnect: None } }), monitor2: Some(PerMonitorConfiguration { monitor_id: "LG", input_sources: InputSources { on_usb_connect: Some(DisplayPort1(0xf)), on_usb_disconnect: None } }), monitor3: None, monitor4: None, monitor5: None, monitor6: None } 18:45:03 [INFO] Display 'LC49G95T S/N 1129855059' is currently set to Custom(0x1) 18:45:07 [DEBUG] (1) display_switch::app: Detected device change. Removed device: "046d:c52f" 18:45:07 [DEBUG] (1) display_switch::app: Detected device change. Removed device: "1ea7:0907" 18:45:07 [DEBUG] (1) display_switch::app: Detected device change. Removed device: "0bda:5411" 18:45:10 [DEBUG] (1) display_switch::app: Detected device change. Added device: "0bda:5411" 18:45:10 [DEBUG] (1) display_switch::app: Detected device change. Added device: "046d:c52f" 18:45:10 [DEBUG] (1) display_switch::app: Detected device change. Added device: "1ea7:0907"

My display-swtich.ini looks like this:

usb_device = "0bda:0411"

on_usb_connect = "Hdmi1"

on_usb_disconnect = "DisplayPort1"

[monitor1] monitor_id = "LG" on_usb_connect = "Hdmi1" on_usb_connect_execute = "echo connected HDMI" on_usb_disconnect_execute = "echo disconnected"

[monitor2] monitor_id = "LG" on_usb_connect = "DisplayPort1" on_usb_connect_execute = "echo connected DisplayPort 2" on_usb_disconnect_execute = "echo disconnected"

I hadn't upgraded in 2 years, so that was my first move.

Then I tried updating the firmware on my monitor.

long->short, I can't see what's going wrong...but I also see that the switch isn't causing the change any more.

What's the right way to debug this?

rajohns08 commented 2 years ago

After adding some log statements, I'm not seeing device_arrived or device_left callbacks ever hit on macOS 12.4. MacBook Pro (16-inch 2019).

rajohns08 commented 2 years ago

I think we might be having different issues, because judging from your logs, your device_arrived and device_left are being hit.

rajohns08 commented 2 years ago

@kcorey, you can give my fork a try in the off-chance it also fixes your issue. I opened a PR here.

kcorey commented 2 years ago

Thanks for writing. Of on holiday now so don't be best my computer a couple weeks.

I'll look when I get back.

kcorey commented 1 year ago

I've got things sorted again (finally).

As it happens there were a few issues. 1) the USB ID of my monitor changed from "0bda:0411" to "0bda:5411" 2) the name of the monitor changed from "LG" to "LC49G95T S/N 1129855059". 3) I had to uncomment the below lines in my config file: on_usb_connect = "Hdmi1" on_usb_disconnect = "DisplayPort1"

Once I sorted those things out it works again! Yay!