how to change monitor input source from command line?

Hi all, I recently faced an interesting conundrum of having to connect a Macbook Pro and an Ubuntu desktop to the same monitor (Dell U3417W). I had to switch the monitor input source from Mac to Ubuntu and vice-versa frequently and the only way to do so was to physically press a bunch of buttons on the monitor. This got cumbersome pretty quickly and I wanted to find a niftier solution. I was already using the same keyboard and mouse to control both using synergy, so I started digging around and this post describes my findings.

Switching from Ubuntu to Mac

My google search led to me to a linux program named ddccontrol which lets one control monitor parameters like brightness, contrast, input source, RGB color levels etc.


Once I had connected both Mac (HDMI-2) and Ubuntu desktop (DisplayPort-2) to the same monitor, it was time to play with the tool. I installed ddccontrol on the Ubuntu using below command.

 sudo apt install ddccontrol


Once installed, you'll need to probe I2C devices to find monitor buses. In my case, /dev/i2c-3 was the device corresponding to my Dell monitor.

 sudo ddccontrol -p

 Detected monitors :
  - Device: dev:/dev/i2c-3
    DDC/CI supported: Yes
    Monitor Name: VESA standard monitor
    Input type: Digital

Finding Control Value

In order to change the input source, we first need to find the control value of the monitor input source setting. You can find this by running below command.

Caveat: If the grep fails, take a look at the raw output.

sudo ddccontrol -d dev:/dev/i2c-3 2>&1 | grep -i 'input source'
Control 0x60: +/4114/4626 C [Input Source Select]

The above output indicates that 0x60 is the monitor input source control value.

Changing monitor input source

In order to change the input source, we need to write the corresponding input source value to the control. You can use the table listed below to find the correct value. In my case, since my Mac was on HDMI-2, I had to write 18.

sudo ddccontrol -r 0x60 -w 18 dev:/dev/i2c-3

Input Source Table

Input Source Value
VGA-1 1
VGA-2 2
DVI-1 3
DVI-2 4
Composite video 1 5
Composite video 2 6
S-Video-1 7
S-Video-2 8
Tuner-1 9
Tuner-2 10
Tuner-3 11
Component video (YPrPb/YCrCb) 1 12
Component video (YPrPb/YCrCb) 2 13
Component video (YPrPb/YCrCb) 3 14
DisplayPort-1 15
DisplayPort-2 16
HDMI-1 17
HDMI-2 18


Switching from Mac to Ubuntu


Unfortunately, ddccontrol is built for Linux distributions and doesn't work on Mac. However, there is an equivalent tool that provides similar functionality titled ddcctl. You can install it by running below commands.

cd /tmp
git clone
cd ddcctl
make && make install

The above command installs ddcctl to /usr/local/bin/ddcctl directory. You can run ddcctl on command line to list all the options it supports.

Changing monitor input source

ddcctl is not as feature reach as ddccontrol but it gets the job done. Since I only had one external display connected, the display value was 1. My Ubuntu desktop is connected to DisplayPort-2, so I had to pass 16 as per above table to change my input source.

ddcctl -d 1 -i 16


Comments powered by Disqus