6 ms·
I use a USB host-side switch [0] to quickly move my keyboard and mouse between my desktop and my laptop's docking station, since my 4k monitor already supports
by ohazi 6y ago
I use a USB host-side switch [0] to quickly move my keyboard and mouse between my desktop and my laptop's docking station, since my 4k monitor already supports multiple inputs, and 4k capable KVMs are expensive and buggy.
In order to make the switch, I push one button on the USB switch, and then select the next input on my monitor (four button presses using the monitor's OSD). There's a great little tool called ddcutil [1] that allows you to send commands to your monitor via the i2c bus embedded in your HDMI/DisplayPort connection, so I tried to write a script to do the monitor input swap on either a key binding or after detecting the appropriate USB event.
It almost worked. My monitor only listens to the i2c bus of the selected input, so I need to run this script on both my desktop and laptop rather than just on the desktop. But apparently there was a bug in the way my (TB3) dock handled forwarding of the DP i2c data to the docking host. And by bug, I mean write forwarding was just not implemented in the kernel driver. So ddcutil would work on my laptop with a direct HDMI connection, but not when it was connected via the dock.
Anyway, long story short:
5.10 fixes this [2], so I'm particularly excited about this release.
[0] https://www.amazon.com/Cable-Matters-Sharing-Computers-Peripherals/dp/B083JKDNRJ/ https://www.amazon.com/Cable-Matters-Sharing-Computers-Perip...
[1] https://github.com/rockowitz/ddcutil https://github.com/rockowitz/ddcutil
[2] https://lkml.org/lkml/2020/9/1/300 https://lkml.org/lkml/2020/9/1/300
- kodah 6y agoMy laptop and desktop are configured the same way. The only difference is that I use a logitech gaming mouse that supports both plugged and wireless connections, so the USB transfer is just my audio source. Its fairly easy to swap the USB cable, but I'm lazy and had dreamed of a device like this. Thanks for sharing.
- chx 6y agoPlease look at https://github.com/haimgel/display-switch https://github.com/haimgel/display-switch
- ohazi 6y agoHa! This is more or less how my shell script works, but it looks way less kludgey. Thanks!
- thejosh 6y agoThis is exactly what I've been wanting, but I didn't do any research into the topic. I love hacker news, thanks so much!
- JamesBrooks 6y agoBeen using this for a while, same situation as above between a MBP and a Windows PC - has been working fairly well!
- GordonS 6y agoI've been using this on Windows for a few months now, and it works great! Only issue I have with it is that it doesn't run as a Windows service - so you have to manually switch the monitor the first time so you can login and start display-switch. I see someone else has opened an issue in the github repo, so hopefully it gets resolved.
- charsi 6y agoThis might help.. https://github.com/winsw/winsw https://github.com/winsw/winsw
- 0xfeba 6y agoI too tried KVM switches and saw they have not changed much in 15 years. No support for higher video modes. Buggy. So I got a USB switch and that worked well for a while with multiple monitors (Dell) that you could assign shortcut keys to the buttons to switch inputs with 2 presses. Now I have a curved Dell and it has a built-in USB switch that works really well that you can assign to inputs. It's a bit slow, switching USB takes as long as it does to switch video inputs, but it appears to be rock solid. The other features, side-by-side and PiP are kind of a joke.
- xnyan 6y ago> switching USB takes as long as it does to switch video inputs High-end KVMs get around this with virtual usb devices. Instead of switching the actual USB devices between computers A and B, they instead create a separate virtual USB device for each computer that always stays connected to each computer and is never switched. When you push the button on the KVM, you are not actually switching between computers, the KVM reads the USB input from the device and then recreates it on the appropriate virtual usb output device. These KVMs are pretty costly. There are some complicated DIY solutions involving arduinos, but a software "KVM" (really just the KM, no V) like https://github.com/debauchee/barrier https://github.com/debauchee/barrier in most situations works just as well, and if the computers are connected via wired ethernet, is rock-solid and adds no perceptible latency.
- philliphaydon 6y agoIs this for sharing a display with the desktop / laptop? Or just the keyboard/mouse? For keyboard/mouse I use Barrier ( https://github.com/debauchee/barrier https://github.com/debauchee/barrier ) which works great for sharing keyboard/mouse between my laptop and desktop.
- ohazi 6y agoI'm sharing the display as well. The USB switch electrically disconnects and reconnects any attached USB devices, moving them between a USB port on my desktop and a USB port on my docking station. I have a keyboard and a Logitech receiver connected to this switch. The advantage of doing it this way is that it works on any operating system without any additional software. Things that might not make it through a HID emulation layer (e.g. scroll sensitivity, firmware updates, RGB LED control(?), etc.) just work the way they would if the peripherals were connected directly (because they are connected directly). You could also add other USB devices to the switch if you wanted, like an audio interface, drawing tablet, thumbdrive, etc. (although you'd want to be careful about unmounting any drives). The video source is set by the monitor. Doing this via the monitor's OSD menu works, and also doesn't require any software, but is annoying. So the small bit of optional software that I've added is a script that waits for the keyboard to disappear (which happens after I press the button on the USB switch), and then tells the monitor to change input. It saves me four button presses when it works, but I can still perform the switch manually if it doesn't. The no-software approach allows this setup to work even if a friend shows up with a TB3 laptop without any special software and wants to work at my desk.
- philliphaydon 6y agoAhhh ok cool. I wasn't quite sure when I read your post but thanks for explaining. It's really interesting. Wonder if it will work with my desktop and raspberry pi.
- no_carrier 6y agoDid you think about having both the laptop and desktop connected via the dock and then using the USB switcher to switch it that way? Then there wouldn't be any messing around with monitor source. Is that even doable? It's the type of setup I want.
- mixmastamyk 6y agoI have a script to change the brightness of my external monitor using ddcutil. It worked until I installed a usb-c thunderbolt dock. Signal didn't seem to make it through. This must be the same bug. To work around it I have to use a second hdmi cable directly connected. It defeats the purpose of having the single dock cable that I was hoping for when I bought it. :-/ Good news though. Maybe when 21.04 (Hirsute Hippo :) comes out I can finally get rid of the second cable.
- ohazi 6y agoYeah, this is almost certainly the same bug. Some more info here [1] [2] [3]. In my case, using the second direct HDMI cable like you did was a non-starter because my Thinkpad only supports 4k at 30 Hz via the built-in HDMI port (!), vs. 4k at 60 Hz if you use the Thunderbolt port or a dock / adapter connected to that port. 30 Hz gave me eye strain after less than 5 minutes. [1] https://gitlab.freedesktop.org/drm/intel/-/issues/37 https://gitlab.freedesktop.org/drm/intel/-/issues/37 [2] https://github.com/rockowitz/ddcutil/issues/11 https://github.com/rockowitz/ddcutil/issues/11 [3] https://github.com/rockowitz/ddcutil/issues/146 https://github.com/rockowitz/ddcutil/issues/146
- mixmastamyk 6y agoYes, I participated in that ddcutil issue. You might try anyway. Believe I use the thunderbolt connection for my monitor, the second direct hdmi connection is used only for sending ddc commands. In other words, both inputs seem to be listened to with my Dell monitor.
- ohazi 6y agoThat is one chonky serial cable... :-P Your monitor must listen to DDC commands from inactive inputs. I think mine doesn't, because this whole problem came about when I realized that my desktop could ask the monitor to switch to the other input, but couldn't ask it to switch back. Apparently a lot of computer monitors only listen to DDC commands coming from the selected input, while TVs almost always listen to them from all inputs, because they often need to do things like "switch to Roku input when the Roku asks, even if some other set-top box is driving the display." If my monitor could do this, I could just run the input switching script entirely on my desktop (based on whether the keyboard has just appeared or just disappeared), and I wouldn't have to send DDC commands via the dock at all.
- isatty 6y agoI use a similar workflow, except I send the i2c stuff straight to the monitor without a docking hub in the middle. I can verify that this works fine on 5.5.11. I use a udev rule to detect a USB 3 hub being plugged in and plugged out, and ddccontrol sends the relevant i2c signals to the monitors. I'm happy with the ddccontrol based switching with 2 computers (linux desktop + mbp), but I want to add an additional computer (mbp) to the mix, so my workflow won't work anymore. Does anyone know of dual head DP KVM switches that work reliability? Googling shows a few options, but the they are old posts and things may have changed. Single head (1 DP monitor + MST) works for the linux desktop but Apple does not support MST on macbooks it seems like[1][2] (I can't even find an official page on apple.com with relevant details). I have tried [3] but it is quite buggy with displays blanking out once every few minutes even with higher quality, DP 1.2 compliant cables (cable length < 1.2m). [1] https://www.dell.com/community/Monitors/P2720DC-use-MST-function-on-MacBook-Pro-16/td-p/7628116 https://www.dell.com/community/Monitors/P2720DC-use-MST-func... [2] https://old.reddit.com/r/MacOS/comments/gliki5/in_2020_why_does_macos_still_not_fully_implement/ https://old.reddit.com/r/MacOS/comments/gliki5/in_2020_why_d... [3] https://www.amazon.com/gp/product/B089LY4S63/ref=ppx_yo_dt_b_asin_title_o01_s00?ie=UTF8&psc=1 https://www.amazon.com/gp/product/B089LY4S63/ref=ppx_yo_dt_b... (select the 2 monitor x 4 computers DP model)
- qwerty456127 6y ago> I use a udev rule to detect a USB 3 hub being plugged in and plugged out, and ddccontrol sends the relevant i2c signals to the monitors. I always wondered if such things are unique features of Linux or available on Windows and Mac as well.
- isatty 6y agoI wouldn’t say it’s unique to Linux but it won’t be (e)udev of course. I use a tiny shell script daemon to listen to console.log events to detect my webcam being turned on to trigger additional Philips Hue based lighting for example. Windows should have something similar.
- jiehong 6y agoYou can check the level 1 tech KVM switches that were designed to be more reliable than others: https://store.level1techs.com/ https://store.level1techs.com/
- mindw0rk 6y agoI'm using this one [0] for quite some time. Works like a charm. Ideal for gaming/work stations switching. Quite expensive though. [0] https://kvm-switch.de/de/AP-552PSK.html https://kvm-switch.de/de/AP-552PSK.html