Created
December 30, 2021 22:12
-
-
Save Voronenko/7fcef0c6b684830c7339b452ffa39824 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The command you are looking for is ddccontrol, available from the regular Ubuntu repository. | |
WARNING! ddccontrol sends data over the i2c bus, which is inherently a dangerous thing to do. Most i2c devices are very low-level and very dumb, one misplaced command can be enough to brick them or at least freeze the computer. That said, DDC/CI is a somewhat standardized, quite established and quite old technology, so the risks is not too high. | |
For this reason, by default, i2c devices are only accessible to root. You will most likely need to prefix all commands below with sudo. (I have voluntarily not done it to ensure you read the instructions and not blindly copy/paste them.) | |
Probing your monitor | |
The first thing to do is to probe the various i2c buses in your computer (mine has 11 such buses...), searching for the one that is actually on the graphics card, connected to the screen. | |
The ddccontrol -p command does that, and shows what it found. Sample output from my computer: | |
Detected monitors : | |
- Device: dev:/dev/i2c-4 | |
DDC/CI supported: Yes | |
Monitor Name: VESA standard monitor | |
Input type: Digital | |
(Automatically selected) | |
Reading EDID and initializing DDC/CI at bus dev:/dev/i2c-4... | |
I/O warning : failed to load external entity "/usr/share/ddccontrol-db/monitor/DELD070.xml" | |
Document not parsed successfully. | |
EDID readings: | |
Plug and Play ID: DELD070 [VESA standard monitor] | |
Input type: Digital | |
Note the I/O warning: it merely means that your monitor is unknown to ddccontrol, so it does not know the description of all the non-standard commands and values it may support. This does not prevent you from issuing the commands, but this may be a trials and errors process. | |
Note also the detected bus name: dev:/dev/i2c-4 in my example. | |
Listing all commands | |
The ddccontrol -d dev:/dev/i2c-4 command reads all the possible controls (from 0x00 to 0xff) and shows the values it found. Of course, you should use the bus found when probing. | |
ddccontrol also shows a description for the controls and values that are known to it; either standard ones, or ones described in XML files. In my example, there is no XML file for my monitor (see the I/O warning above). | |
Querying a value | |
The ddccontrol -r 0x10 dev:/dev/i2c-4 queries the current value of the 0x10 control. Example output: | |
Reading 0x10... | |
Control 0x10: +/21/100 C [Brightness] | |
The current value is the number in the middle, 21 in my example. The value after that is supposed to be the maximum, but this seem to only work for ranged values (such as brightness and contrast), not so much for list items. | |
Setting a value | |
The ddccontrol -r 0x10 -w 25 dev:/dev/i2c-4 sets the value of the 0x10 control. Example output: | |
Writing 0x10, 0x19(25)... | |
Control 0x10: +/25/100 C [Brightness] | |
Note that you can set values in hexadecimal or decimal formats. In my example, I used decimal. | |
Changing monitor input source | |
I found the command and values to use to switch my monitor inputs. It works well, by you will of course need to experiment to find the values for your monitor. Mine is a Dell UltraSharp U2515H. | |
Control 0x60 [Input Source Select] | |
Value 15: DP | |
Value 16: mDP | |
Value 17: HDMI (MHL) 1 | |
Value 18: HDMI (MHL) 2 | |
The values are in the same order as the Input Source menu in the monitor. | |
For example, switching to DP: ddccontrol -r 0x60 -w 15 dev:/dev/i2c-4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment