Turn a $30 USB switch into a full-featured KVM
This utility watches for USB device connect/disconnect events and switches monitor inputs via DDC/CI. This turns a simple USB switch into a full-fledged KVM solution: press one button on your USB switch and all your monitors connect to a different input.
It is supposed to be installed on all computers that could be connected to these monitors, since the app only switches monitors "one way" and relies on itself running on the other computers to switch it "the other way" as needed.
The app should function on MacOS and Windows. Linux support is planned in a future release. Most of the code is in Rust, with the exception of DDC support on MacOS, which is done via statically-linked Swift library.
The configuration is pretty similar on all platforms:
On MacOS: the configuration file is expected in
~/Library/Preferences/display-switch.ini On Windows: the configuration file is expected in
Configuration file settings:
usb_device = "1050:0407" monitor_input = "Hdmi1"
usb_device is which USB device to watch (vendor id / device id in hex), and
monitor_input is which monitor input to switch to, when this device is connected. Supported values are
DisplayPort2 If your monitor has an USB-C port, it's usually reported as
DisplayPort2. Input can also be specified as a "raw" decimal or hexadecimal value:
monitor_input = 0x10
- On MacOS: the log file is written to
- On WindowS: the log file is written to
Building from source
Install Rust, then do
cargo build --release
Running on startup
target\release (where it was built in the previous step) to
C:\Users\Username\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup (replace Username with your Windows user name).
# Get your INI file in order! (see above) cp target/release/display_switch /usr/local/bin cp dev.haim.display-switch.daemon.plist ~/Library/LaunchAgents/ launchctl load ~/Library/LaunchAgents/dev.haim.display-switch.daemon.plist