December 10, 2023

Automatically switching input sources on Dell Monitor (U3821DW) with inbuilt KVM switch

My external monitor (Dell U3821DW) has a inbuilt KVM switch that can be controlled either through the joystick controller on the monitor (reaching out to the monitor everytime you want to switch is a pain) or through the Dell Display and Peripherals Manager (DDPM). The latter is only available on MacOS or Windows.

My home setup has my work/personal MBP pro connected to the monitor via the USB-C hub (inbuilt) and my workstation running linux is connected via HDMI/USB-B. My keyboard and mouse are both connected via a USB-A hub that is connected to the monitor directly.

From MacOS I can use a hotkey setup via DDPM to switch to HDMI as the input source and the monitor automatically switches over the peripheral USB input to my workstation (the KVM part).

However from linux, I had to setup ddcutil to be able to switch between the input sources (and back to my MBP).

ddcutil allows you to probe for the capabilities on each external monitor that is detected :

~ sudo ddcutil detect                                 
Display 1
   I2C bus:  /dev/i2c-3
   EDID synopsis:
      Mfg id:               DEL
      Model:                DELL U3821DW
      Product code:         41387
      Serial number:        5J82073
      Binary serial number: 809060684 (0x3039494c)
      Manufacture year:     2022,  Week: 42
   VCP version:         2.1
~ sudo ddcutil capabilities | grep "Input Source" -A 5
   Feature: 60 (Input Source)
         1b: Unrecognized value
         0f: DisplayPort-1
         11: HDMI-1
         12: HDMI-2

We don't see the USB-C input source here, my best guess was that "Unrecognized value" (0x1b) is the USB-C input as the output accounts for all the other video input sources. So to switch back to my MBP from linux, I would run :

~ sudo ddcutil setvcp 60 0x1b

NOTE: 60 here is the Virtual control panel (VCP) code for the "Input source" command set. Refer to the VESA Monitor Control Command Set for more information on VCP etc.

To automate this, I setup a script in my local $PATH that I can run from the terminal. You can also setup shortcuts in your favorite desktop linux environment to trigger this command.

No comments:

Post a Comment