23 July, 2018

ddccontrol - automatic change display input

ddccontrol - change display input


In my DKVM setup, I always use my 2nd graphicscard for my guests. Sadly my monitor does not have automatic input detection, so a little trickery is needed to switch input.

For my DKVM host OS, I use the DVI input.
For my VM guests, I use the DisplayPort input.

ddccontrol - probing

ddccontrol -p is used for probing the I2C bus for displays.
To find the information needed, first find the I2C bus for the display - it should look similar to this
In my case, my monitor is in dev:/dev/i2c-17


Finding the needed i2c address and values.

Still looking at the output from "ddccontrol -p", find a section like "Input settings"

In my case, the i2c address for setting inputsource is 0x60, and the accepted values are
15: DisplayPort
3:  DVI
4:  HDMI
1:  VGA


Writing to the i2c address

To set another display input, use the information gathered, and use "-w" to write
example : ddccontrol -r 0x60 -w 15 dev:/dev/i2c-17
This will set the input source to DisplayPort


Wrapping it up


In my case, I need to set the input to DisplayPort when my Linux guest is starting, and set it back to DVI when I am done.
While there are plenty of ways to run scripts in startup/shutdown, I opted for the easy solution - and just went with an old-fashioned OpenRC init style script, and placed symlinks to the different rc levels.

/etc/init.d/ddccontrol

 #!/bin/sh  
 case "$1" in  
      start)  
      /usr/bin/ddccontrol -r 0x60 -w 15 dev:/dev/i2c-17  
      ;;  
      stop)  
      /usr/bin/ddccontrol -r 0x60 -w 3 dev:/dev/i2c-17  
 esac  

And the required symlinks

 #!/bin/sh  
$ find /etc -iname "*ddccontrol" -exec ls -l {} \; 2>/dev/null
lrwxrwxrwx 1 root root 20 Jul 23 12:49 /etc/rc6.d/K99ddccontrol -> ../init.d/ddccontrol
lrwxrwxrwx 1 root root 20 Jul 23 12:52 /etc/rc0.d/K99ddccontrol -> ../init.d/ddccontrol
lrwxrwxrwx 1 root root 20 Jul 23 12:49 /etc/rc3.d/S01ddccontrol -> ../init.d/ddccontrol
-rwxr-xr-x 1 root root 148 Jul 23 12:48 /etc/init.d/ddccontrol


No comments:

Post a Comment

Danish PC keyboard layout on MacOS

As I am primarily a GNU/Linux user, and mostly just using MacOS at work - I do not own (or want to own) a MacOS specific keyboard at home. ...