16 ms·
Display-switch: Turn a $30 USB switch into a full-featured multi-monitor KVM
- serverlessmom 5y agoReally wish I'd seen this article before I spent $90 on a KVM splitter off Amazon. Whoops!
- shadeless 5y agoThis looks fantastic, I was recently disappointed to learn that there don't seem to be any good KVMs under ~$200, that support anything higher than 4k@60Hz. Apparently Thunderbolt/DisplayPort are not really a thing yet for some reason, so I ended up getting a USB (KM) switch instead. With this project, it looks like I'll be able to have my cake and eat it too.
- VTimofeenko 5y agoMake sure that the monitor you are using actually supports input management through DDC. I have seen some monitors that expose only the color management.
- lightbendover 5y agoI found the same problem roughly a couple years ago. I ended up building a very specific solution (switch input mode based on specific USB changes) that is more or less a subset of of the functionality here. I am now having near daily issues with the KM (a ~$30 one that was the only one I could find that really meet my needs) box. There is tons of room on the market for a good prosumer solution to this problem.
- vladvasiliu 5y agoI've managed to find a cheap 2-port DP KVM that pretends it's able to do DP 1.4 / 8k @ 60 Hz. I can only confirm it works well at 4k@60 Hz, since that's the best my screen can do. One pro is that it's able to get power from any of the USB inputs, so no extra cable! One con is that for some reason it only does USB 2... Amazon FR link : https://www.amazon.fr/gp/product/B08Q7J3B82 https://www.amazon.fr/gp/product/B08Q7J3B82
- chx 5y agoCheck https://dancharblog.wordpress.com/2021/07/05/usb-c-gen2-bi-directional-switch-with-pd/ https://dancharblog.wordpress.com/2021/07/05/usb-c-gen2-bi-d... end of post links to DP and HDMI 2.1 switches
- mathfailure 5y agoI've read the project's description and failed to figure what it does. What's a 'USB switch'? Where should this device be connected to? "press one button on your USB switch and all your monitors connect to a different input." - if the USB switch has buttons - why would I even disconnect/reconnect it? The project's description is shit.
- chromatin 5y agoCame to make the same comment. Read it twice and am still in the dark.
- deleted 5y ago[deleted]
- VTimofeenko 5y agoI presume USB switch refers to a USB hub with two "output" USB cables, one of which is active at a time. One can toggle the active by pressing a physical button on the switch. Use case: keyboard and mouse are plugged into the switch and you can quickly toggle them between two laptops without messing with the cables.
- kenny11 5y agoYes, this is exactly what it is. Basically a KVM switch without the V. I've been using the display-switch software for months and it's fantastic. Using the inputs on the monitors to do the video switching instead of an external KVM switch means that you don't have to worry about finding a KVM switch that can handle the signal bandwidth required (in my case, three 4K60 HDR DisplayPort monitors, which is not a use case for which most KVM switches are designed). This is the USB switch I use with it: https://www.iogear.com/product/GUS402/ https://www.iogear.com/product/GUS402/
- nkrisc 5y agoWhen you use a switching USB hub to switch your USB peripherals from one device to another, it detects the change and uses DDC to also change your monitor’s input setting. It needs to run on each computer in the setup since it watches for the USB devices to connect. https://duckduckgo.com/?q=usb+switch https://duckduckgo.com/?q=usb+switch
- JustSomeNobody 5y agoInteresting. My current set up is a usb switch and an hdmi switch, so two buttons to push.
- Rebelgecko 5y agoI have a similar setup, but unfortunately I'm stuck with it because my Acer monitor doesn't support the necessary DDC commands
- nkrisc 5y agoSpeaking from experience, download a program that can show what DDC commands your monitor supports before you bother. Mine supports many except… switching inputs (0x60 if I recall). Documentation for most consumer monitors is pretty lacking in this regard, it seems to be a feature mostly on monitors targeted to the professional market.
- rektide 5y agoI was pretty shocked that most of the ddcutil & other similar programs on Linux weren't working for two of my monitors. The utils couldn't even detect the DDC display. But I told it what i2c bus to send to & what commands to issue, and it turns out my monitors had a pretty wide range of commands. Reminds me of an i2c motor controller I bought years ago, based off some avr microcontroller. I spent an afternoon trying to understand how I'd hooked things up wrong, trying to understand why I couldn't read the control values. Turns the soft i2c interface just didn't implement reading values off the controller at all, but served ok if I treated it as a write-only device. Frustrating tricky devices. Sometimes they lie. But yeah, also a >15% chance your monitor doesn't support switching inputs via DDC/CI. Would be so nice if review sites would cover this sort of thing. As it is, it's just a tech-secret, something invisible to the market, no push to include it, no points deducted for getting it wrong/bad. It leaves a lot of room for the situation to sit & not improve. Better reviewing would help move things along.
- nkrisc 5y agoI couldn’t even find any documentation for my monitor. ddcutil worked great for everything it did support, just not the one thing I actually cared about.
- alufers 5y agoSometimes it also the availability of commands depends on the cable/adapter used. If I connect my monitor directly via HDMI to my laptop I can send all the DDC commands I want, but when I use an USB-C -> DisplayPort cable ddcutil couldn't event detect the monitor. Sadly I must use this cable, because it's the only way I can get 4K@60FPS.
- walrus01 5y agofrom a purely software perspective and sort of the inverse of this, everyone should be aware of barrier, the fork/continuation of synergy https://github.com/debauchee/barrier https://github.com/debauchee/barrier the general concept is you could have 2, 3, 4 or more individual desktop PCs at one desk, each connected to their own displays, and one keyboard and one mouse. The keyboard and mouse are on the primary workstation, you can roll the mouse off the edge of one screen and onto another. The secondary and tertiary workstation PCs have no keyboard/mouse i/o plugged into them, just power, ethernet and display.
- johnwalkr 5y agoI use this and it works very well. I also want to add that it shares the clipboard across all of the PCs. In fact I can even copy from my iPhone and paste into a windows PC, via my MacBook. I also have a few PCs and use the input selection on my monitor to achieve the KVM aspect. The only issue I found is that if no monitor is actively connected to a windows machine, barrier server doesn’t work well, and also you can’t Remote Desktop to it. I solved both of these by adding a dummy HDMI dongle, set to a low resolution so application windows can’t get stuck there. Not a perfect solution but the best I’ve found since my goals were: to use a Bluetooth keyboard and mouse, and not worry about limitations to refresh rate, etc.
- firecall 5y agoI can never get this to work! Installed on macOS 12.1 and Windows 10 or 11, and nothing happens! It sees the client and server just fine. But never moves over! Maybe I should the try the paid Synergy! The Logitech solution has the lag when you bang against the side of the screen, and thats no good! :-)
- stonewareslord 5y agoYou have to configure the server by adding the clients screen to the left/right of yours. Also, I always use IP Address of the server on the client.
- 5y ago
- amelius 5y ago> the app only switches monitors "one way" and relies on itself running on the other computers to switch it "the other way" as needed. Too bad, I often need a KVM switch exactly when I'm installing a new OS on an embedded system (and from that point on I don't need the switch because I can just use the network to log in and install software). So this solution doesn't work for me at precisely the moment I need it.
- 55873445216111 5y agoNot true. I run display-switch on only one of my two computers and the monitor switches back and forth with my USB switch.
- R0b0t1 5y agoMost have an autosetup that can get you to a shell via ssh, worth looking into. It also seems like you can switch from any computer currently connected. Have your normal computer switch to the other computer's input.
- lillecarl 5y agoThe protocol runs over the USB cable to your monitor, so whichever monitor has that cable plugged will be able to send the commands. I'm using this command sudo virsh start win10;sudo ddcutil -d 1 setvcp 0x60 0x03 To start Windows and change display input to DVI, which is the GPU for my Windows VM. Changing back can be done either by powering the VM down or running the command sudo ddcutil -d 1 setvcp 0x60 0x0F
- beastie29a 5y agoPrevious discussion: https://news.ycombinator.com/item?id=24357308 https://news.ycombinator.com/item?id=24357308 Author's site: https://haim.dev/posts/2020-07-28-dual-monitor-kvm/ https://haim.dev/posts/2020-07-28-dual-monitor-kvm/ BTW, for some reason I could never get this working on my Hackintosh, keeps crashing the system and never took the time to look into it.
- 55873445216111 5y agodisplay-switch has saved me so much time and has been so useful during work from home. thank you to the author.
- milofeynman 5y agoI've been using this since it was created and it works fantastic. The only problem is my bad monitor has like a 5 second timeout if no input is detected!
- fiddyschmitt 5y agoIf you'd like to use a GUI, I wrote SimpleKVM: https://github.com/fiddyschmitt/SimpleKVM https://github.com/fiddyschmitt/SimpleKVM The GUI makes things (hopefully) a little easier to set up. It was inspired by Haimgel's project. It's nice to be able to run the monitor at native resolution and refresh rate, without paying hundreds for a KVM.
- ranger_danger 5y agoFair warning to others, this project has no license, is Windows only and also requires an external closed-source/proprietary binary that is included in the repo.
- fiddyschmitt 5y agoThanks ranger, I had completely forgotten about ControlMyMonitor.exe. That's how the program originally switched inputs, but was since replaced by win32 calls in MonitorController.cs. I've removed that external dependency and published a new release. Yes Windows only; I'll add mac & linux when I get a bit more time. Cheers, Fidel
- lardo 5y agoI control my monitor from a pi zero hooked up to a cheap vga/usb switch. If your monitor supports ddc/ci, ddcutil makes communicating over hdmi dead simple. The button from the usb switch, as well as a wire from the switch's chopped off vga cable is fed into gpio, as is a 4x4 input pad I use to control it from. Pressing D on the pad toggles displays and triggers the USB switch, A50# sets the volume to 50%, B50# brightness to 50%. The big downside is that switching inputs on my monitor takes ~5 seconds where a proper kvm would be instant.
- amelius 5y ago> The big downside is that switching inputs on my monitor takes ~5 seconds where a proper kvm would be instant. This is something the industry should address. It's ridiculous.
- octagons 5y agoI have addressed this problem by using a 4x4 USB switcher from Rosewill and an HDMI matrix, such as those used by broadcasting or A/V signage industries. I started with an 8x8 matrix and now have a 16x16. It’s dead simple to give each of the 4 or so computers I have hooked up to them 3 or so monitors, and I can swap any video source to any sink using a web interface. The matrix isn’t cheap (approximately $1200) but after using it for around 4 years, I honestly couldn’t think of using my workstation any other way.
- adanto6840 5y agoDoes it support 4k@60? Can you configure EDID handling, or any potential HDCP issues (and stuff like HDR, ethernet-over-HDMI, etc)? Would be curious what make/model of matrix you're using. There's plenty of different hardware out there but not a whole lot of reviews; and my experience with the HDMI interface has, on the whole, not been the best. HDMI is great for consumer stuff, and for plugging in a generic source to a screen (AppleTV, Firestick, Xbox, cable box, etc) -- but, as soon as you want to do anything even slightly more advanced, you often run into hiccups quite rapidly (EDID & handshake/negotiation issues, cable & port quality, HDCP, etc). I have several 'screens' (TVs) and I wanted to be able to mirror my 'main' display to other screens on occasion, for instance. It's easy to do that with a cheap-ish "splitter" [though they are finnicky), but if you want to "scale" that at all then you rapidly run into proprietary and/or high-cost solutions or have to make substantial quality & capability concessions (and >=10G LAN connectivity is pre-existing). I was annoyed by the lack of good options & and the extreme prices and/or the limitations of the options that do exist -- enough so that I'm working on (and already actively using) my own IP-based "video distribution" solution, heh.
- octagons 5y agoThe 16x16 one I bought does. It supports (some form of) HDMI 2.1. The EDID management for all matrices I’ve tested is a bit odd. Pass through doesn’t always work with most monitors, and you can specify a generic EDID from a preconfigured list, upload your own (only one) EDID file, or select “COPY_FROM_INPUT_1” for any or all outputs. The problem is that sometimes you might want input 1 to go to output 2, despite normally sending it to output 1. I have to manually change the EDID profile. I can’t say how well a balun/extender setup will work but I believe they make boxes that specifically do that - a combination matrix and extender. I have no issues with HDCP. Happy to answer any other questions. Search Monoprice for Audio/Video splitters but pay very close attention to the description. Make sure you understand the number of sources and sinks it offers.
- mmastrac 5y agoI bought a fantastic curved Samsung monitor and it supports reading from the port that tells you the current input but not setting it. It also has the worst possible input switcher that cycles until it finds a valid input. I wish it were easier to hack on monitor firmware. I'd love to improve it.
- causi 5y agoIt's quite infuriating when you have a display that changes input if it's not receiving and a source that switches off unless it's told the display is showing. You end up having to play a timing game to get both devices on at the same time before one of them turns off or changes.
- xcambar 5y agoI cannot guarantee I'd react quietly nor patiently should I be confronted to this. I cannot guarantee that. At. All.
- freen 5y agoI’ll never buy anything from Samsung again. The software on their otherwise delightful hardware is absolute crap.
- Damogran6 5y agoOr their dryers...or their dishwashers...I hear their phones are okay...It sucks when a multinational conglomerate has a sketchy quality issue.
- 3np 5y agoThe phones are terrible too, these days. I bricked a phone and lost access to all data on it by trying to back it up. Every Galaxy generation has gotten worse and worse in terms of preinstalled malware that takes a lot of effort and care to disable (if possible at all). The only thing I would still buy from Samsung these days is storage devices.
- syntaxing 5y agoMaybe I missed it (on mobile) but which switch does this use? Or does anyone have one they recommend?
- synergy20 5y agoI have a $250 TESmart HDMI/keyboard/mouse switch, after 6 months I have to power cycle it each time when I woke up the computer. Unreliable. Also bought Synergy that works fine but I need keep the software running(a wifi switch will lose the connection, so it's not the same as the hardware kvm switch). I now use usb-switch for keyboard/mouse only, and use my monitor's own button to switch displays, so far it is not convenient but "works".
- jpitz 5y agoIf you bought the switch from them, their support is pretty good. I would recommend reaching out to them. Otherwise I guess reach out to who you bought it from.
- sharken 5y agoExactly the same solution here using the Aten US224 device - https://www.amazon.com/Aten-Corp-User-Port-US224/dp/B00B1RX0L2 https://www.amazon.com/Aten-Corp-User-Port-US224/dp/B00B1RX0... One of the computers is a work issued laptop and with this solution i won't have to install any software. The monitor is rather slow to switch inputs, but otherwise all is good. The only visible thing on the desk is the button for switching USB devices.
- intrepidhero 5y agoNeat! Similarly, I've been using ddcutil on Linux and a stupid python script on Windows to switch video inputs. Janky as it is, it's more reliable than any KVM I've ever used, and I've tested quite a few. Now for my 2022 project I want to build one those promicro/QMK based custom keyboards with a direct I2c connection to my monitor and control it via hot keys. Eventually I'd add promicros for each computer all talking I2c and the keyboard is smart enough to forward keypresses to the active computer. That's my idea anyway.
- mfwit 5y agoVery interested in your QMK approach!
- Tempest1981 5y agoAny recommendations for a good 27" 4k display that supports DDC?
- Waterluvian 5y agoWon’t this have a painfully long delay as the monitor negotiates the different input port? Not only does every monitor I’ve owned take seconds to do this, it often screws with the desktop layout and such when display devices seemingly come and go. Or am I misunderstanding this?
- gsich 5y agoNo, all monitors I have used are connected (as in the OS sees the monitor) even if not the current active input.
- anonymousiam 5y agoThanks for posting this! I did not know that I had control of my monitor features this way. My LG 27UK850-W reports the following capabilities when queried. (First I ran "ddcutil detect" to see what it said.) Invalid display I2C bus: /dev/i2c-15 EDID synopsis: Mfg id: LGD Model: Serial number: Manufacture year: 2013 EDID version: 1.4 DDC communication failed This is an eDP laptop display. Laptop displays do not support DDC/CI. Display 1 I2C bus: /dev/i2c-17 EDID synopsis: Mfg id: GSM Model: LG HDR 4K Serial number: Manufacture year: 2018 EDID version: 1.3 VCP version: 2.1 So knowing that my LG monitor is display device #1, I then ran "ddcutil -d 1 capabilities" MCCS version: 2.1 VCP Features: Feature: 02 (New control value) Feature: 04 (Restore factory defaults) Feature: 05 (Restore factory brightness/contrast defaults) Feature: 08 (Restore color defaults) Feature: 10 (Brightness) Feature: 12 (Contrast) Feature: 14 (Select color preset) Values: 05: 6500 K 08: 9300 K 0b: User 1 Feature: 16 (Video gain: Red) Feature: 18 (Video gain: Green) Feature: 1A (Video gain: Blue) Feature: 52 (Active control) Feature: 60 (Input Source) Values: 0f: DisplayPort-1 10: DisplayPort-2 11: HDMI-1 12: HDMI-2 Feature: AC (Horizontal frequency) Feature: AE (Vertical frequency) Feature: B2 (Flat panel sub-pixel layout) Feature: B6 (Display technology type) Feature: C0 (Display usage time) Feature: C6 (Application enable key) Feature: C8 (Display controller type) Feature: C9 (Display firmware level) Feature: D6 (Power mode) Values: 01: DPM: On, DPMS: Off 04: DPM: Off, DPMS: Off Feature: DF (VCP Version) Feature: 62 (Audio speaker volume) Feature: 8D (Audio Mute) Feature: F4 (manufacturer specific feature) Feature: F5 (manufacturer specific feature) Values: 00 01 02 (interpretation unavailable) Feature: F6 (manufacturer specific feature) Values: 00 01 02 (interpretation unavailable) Feature: 4D (unrecognized feature) Feature: 4E (unrecognized feature) Feature: 4F (unrecognized feature) Feature: 15 (unrecognized feature) Values: 01 06 09 10 11 13 14 28 29 32 44 48 (interpretation unavailable) Feature: F7 (manufacturer specific feature) Values: 00 01 02 03 (interpretation unavailable) Feature: F8 (manufacturer specific feature) Values: 00 01 (interpretation unavailable) Feature: F9 (manufacturer specific feature) Feature: E4 (manufacturer specific feature) Feature: E5 (manufacturer specific feature) Feature: E6 (manufacturer specific feature) Feature: E7 (manufacturer specific feature) Feature: E8 (manufacturer specific feature) Feature: E9 (manufacturer specific feature) Feature: EA (manufacturer specific feature) Feature: EB (manufacturer specific feature) Feature: EF (manufacturer specific feature) Feature: FD (manufacturer specific feature) Values: 00 01 (interpretation unavailable) Feature: FE (manufacturer specific feature) Values: 00 01 02 (interpretation unavailable) Feature: FF (manufacturer specific feature)quirred So I pretty much have control of all monitor features!
- superkuh 5y agoIt's cool but it only works if you have a rust compiler that can actual compile this (1.55.0) and no one does. That means you have to install a compiler from outside of your system repositories 100% of the time. Is suggesting everyone, curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs https://sh.rustup.rs | sh ... really such a great idea? Even ignoring the curl | sh it's going to bork many systems now having two rusts. Rust projects you're supposed to compile are not ready for use by anyone but other bleeding edge Rust devs.
- vhodges 5y agoUnder actions, the project is being CI'd and the artifacts are kept there eg: https://github.com/haimgel/display-switch/actions/runs/1528440978 https://github.com/haimgel/display-switch/actions/runs/15284... But yeah, actual releases would be nice.
- edgan 5y agoSadly the standard these days is compile everything in a container. Avoid any conflict by taking the path of least resistance.
- superkuh 5y agoI'd argue that that is a failure install and failure to compile. You don't have a binary that can run on your actual system. When I run MS Office in a Windows virtual machine I am running it but it is not cross-platform or running on Linux. I'm virtualizing it. The same applies here.
- cowtongue 5y agoAn alternative approach that I've taken is to have the HDMIs from my work desktop plugged into a capture card on my main Windows desktop. I then use the preview from OBS to see the display and also hear the audio. Still need a separate keyboard + mouse, but I like being able to move/minimize my work OBS window off to the side when I'm not actively working. I also use this setup with gaming consoles so that I don't have to dedicate an entire monitor. https://github.com/obsproject/obs-studio https://github.com/obsproject/obs-studio
- bmurphy1976 5y agoHow's the latency?
- cowtongue 5y agoI don't notice it when using it for work. I barely notice it when using it for console games. Probably wouldn't want to use it for competitive shooters, but non-issue for most other games. Few more notes: - I use PCIE rather than USB for the capture card - Can be costly if you need 4k + multiple inputs (for multiple "monitors" as different OBS windows) - I had issues getting the capture card to recognize scaled HiDPI resolutions from my work Mac
- deleted 5y ago[deleted]
- crtasm 5y agoYou can do this without a capture card using https://ndi.tv/tools/ https://ndi.tv/tools/ - other clients on your LAN can view in OBS or with the included program. I'm yet to try it with 4k. No help with consoles of course, and perhaps not an option for a work machine. edit: feature list also mentions "KVM remote control of any workstation running Scan Converter from NDI Studio Monitor"
- gbraad 5y agoI use NDI a lot, but with a phone as webcam, or from obs to obs, scan converter, audio stream between devices like ipad/iphone/Android to desktop... But it is demanding to encode this way. HDMI capture does only use bandwidth over the USB or pcie bus, while ndi uses cpu or gpu.
- bob1122 5y agoI love this!
- hsbauauvhabzb 5y agoOff topic, but how are kvms / sub switches when it comes to security? Could a compromised computer listen for keystrokes or send input to an adjacent node or similar?
- mritun 5y agoPSA: Many 4K Dell monitors (like my Dell UltraSharp U3219Q ) have a built-in KVM switch and they support full DDC commands for switching the input as well (over HDMI, DP and USBC). I can control them from Mac and Linux with hot keys that trigger the appropriate ddc commands.
- bmitc 5y agoHowever, they're currently unobtanium. I've been wanting one to solve my working from home problem to allow me switch computers with the same setup.
- runjake 5y agoWhich is unobtanium? I just ordered a Dell 4K from Amazon about 5 days ago and it got here in 3 days.
- bmitc 5y agoThe one specifically mentioned... As well as Dell's 40" ultrawide, that also has the built-in KVM (there are not that many models that have the built-in KVM).
- runjake 5y agoRight. I ordered one on Amazon (but Dell is the seller) and got it a few days later. Amazon shows they (U3219Q) are still in stock.
- mehrdada 5y agoLenovo T32p-20 is also pretty good and not only obtainable (I obtained three just a couple days ago), but currently available at a discount.
- bmitc 5y agoI'm not sure why people are responding telling me that random monitors are available. Do they have built-in KVMs? If not, they aren't what I'm looking for.
- jonathanlydall 5y agoAway from home at the moment, but this looks like it will “complete” my current set up very nicely. I have 2x Dell P2319H (1080p) monitors and have my work laptop connected via DP with my gaming desktop connected via HDMI. Then I have a dumb USB switch with a button on it to switch my USB devices between the two computers. If the other computer is off/sleeping the screens most of the time automatically switch to the correct inputs, but sometimes I need to use the screen controls to do it. This set up cost 10s of dollars as opposed to 100s for a proper KVM switch and it’s worked pretty well for the last 2.5 years. I’ll try this utility when I get home and it will hopefully make it so the USB switch’s button is all I’ll need to press and it will work, even if both the computers are turned on.
- GordonS 5y agoThis is really similar to my own setup, only difference being my monitors are 3k and a portrait 1200p. Been using Display-switch for something like 2.5 years too, and never had an issue with it!
- alin23 5y agoLunar (https://lunar.fyi https://lunar.fyi) supports up to 3 hotkeys to switch input using DDC. Also the functionality is completely free, the Pro license isn’t needed if you only switch inputs and occasionally adjust brightness or volume. This might be a more comfortable solution if your monitor allows input switching through DDC. https://static.lunar.fyi/img/input-key/1920_input-key.png https://static.lunar.fyi/img/input-key/1920_input-key.png
- yalok 5y agoLunar worked great for me on MacBook Pro 2020 (2 monitors, one connected over USB-C to USB-C cable, another one over USB-C to DisplayPort), but doesn’t work on for the same monitors connected to MacPro via 2 HDMI cables… Any idea why?
- alin23 5y agoThe HDMI port on most recent Mac devices uses a converter chip inside to convert the signal to DisplayPort internally. That chip has DDC/CI blocked in its firmware and there's no way to enable it.
- alanfranz 5y agoPSA: if you look in many shops, you can find a number of cheap usb switches and a number of cheap HDMI switches. Buying those two pieces will save money if compared to an integrated kvm switch.
- josteink 5y agoWhile the readme tries its best to explain how this works, I’m still not sure I get it 100%. It would definitely help having a figure or diagram showing how things are meant to be wired up.
- ranma42 5y agoMy shell-script solution I've been using for the last year or two: #!/bin/bash src="pc" while true; do lsusb -d 04d9:a0d1 >/dev/null # Keyboard connected? ret=$? if [ $ret -eq 0 -a "$src" != "pc" ]; then src="pc" ddcutil --noverify setvcp 60 0x0f # Switch monitor input to DP elif [ $ret -eq 1 -a "$src" = "pc" ]; then src="laptop" ddcutil --noverify setvcp 60 0x11 # Switch monitor input to HDMI fi sleep 1 done
- ur-whale 5y ago> sleep 1 One second latency ... not ideal. Is there any way to sleepwait on a USB config change instead? [EDIT]: this might help: https://stackoverflow.com/questions/469243/how-can-i-listen-for-usb-device-inserted-events-in-linux-in-python https://stackoverflow.com/questions/469243/how-can-i-listen-...
- jabl 5y agoThis is a fantastic project. I'm using it with a cheap usb switch to share screen, keyboard and mouse between my work laptop and home desktop. My only gripe is that when I press the USB switch to change inputs, I must follow with a press on the keyboard to wake up the other computer, otherwise the monitor sees that the new input has no signal and switches back to the previous input. In which case I must either manually change inputs on the screen, or press the usb switch a couple more things to try again. But I guess there's not much display-switch can do about that..
- bananasbandanas 5y agoCouldn't display-switch send a keypress (something that doesn't do much otherwise, like F15) automatically? You could probably get that result at the moment using the external command feature and something like xdotool (on Linux)
- pm215 5y agoYes, or send a fake mouse move. It does this already when running on Windows or OSX; there's an open issue for adding the Linux host support: https://github.com/haimgel/display-switch/issues/27 https://github.com/haimgel/display-switch/issues/27 I reckon it's probably 25 or 30 lines or Rust if you make it use the uinput crate to create a fake input device and send a mouse-move event that way.
- 123pie123 5y agojust incase (like me) you haven't heard of DCC/CI before https://appuals.com/what-is-ddc-ci-and-how-to-use-it/ https://appuals.com/what-is-ddc-ci-and-how-to-use-it/
- jarenmf 5y agoI kind of feel disappointed of myself for not hearing of it before although I have searched for a way to script brightness control of my monitors and ended up using suboptimal xrandr for it
- kuon 5y agoI use a similar setup with a hotkey, but the downside is that my monitors take about 5 seconds to switch, which in my case is a serious slow down. I do not know if other monitors would be faster. I looked at KVM that support high resolution, but they are insanely expensive and I am not even sure they would not introduce any latency.
- esjeon 5y agoHmm, I believe someone should've already worked on a pure-software solution for this. I mean, when you say KVM, you gotta double tap Scroll Lock.
- stutteringsteve 5y agoCan anyone concisely explain how this hack works, as if one were to introduce it to a five year old? I'm having a hard time understanding how a USB switch can manipulate a monitor, directly or indirectly, to behave as an alternative to a KVM switch. The project README fails to provide practical examples and detail this hack in the simplest way possible. I'd love to have this solution working for a personal homelab, as prices for KVM switches are too high to financially bear. If I get this solution working, I will contribute back to the README to address this issue. UPDATE: Never mind! I found a relevant thread: https://news.ycombinator.com/item?id=29609573 https://news.ycombinator.com/item?id=29609573
- nsonha 5y agoWhat does this even mean, turn an already switch to... a switch? Isn't an "USB switch", whatever that means, that can connect to multiple monitors (type C?), already a KVM switch?
- thefunnyman 5y agoCan anyone recommend hardware for this? I have a cheap powered USB switch from Amazon I was using but it’s been giving me stuttering issues with my mouse which is a nonstarter for use with a gaming desktop. I’ve also had to unplug and reply my usb DAC each time I switch to get it to work properly.