Read someone's post a year or so back about using DDC/CI to control the monitor settings from the command line, I've faffed on and off but struggled finding a ddc tool that worked until recently. So decided to write this guide up as this topic doesn't come up often so thought some might find it useful.
Host: Ubuntu 16.04 | Intel IGP for host only | GTX 970 for passthrough
Step #1
Nabbed the ddctool source from http://www.ddctool.com/, compiled, added my local user to the i2c group. Couple of dependencies I needed to work through the **** ache being the libxrandr-dev package but that was only because it was new to me.
Code:
ddctool detect <--finds and lists the monitors and confirms capability to control them ddctool capabilities <--lists out all the monitor functions the tool can read and control. For me Feature 60: (Input Source) has 3 possible values applicable 0x01, 0x03, 0x11 which are my VGA, DVI and HDMI coectors on the monitor. ddctool getvcp 60 <--retus the current value/setting for this feature. For me this retus "VCP code 0x60 (Input Source ): DVI-1 (sl=0x03)" as an example ddctool setvcp 60 0x11 <--switches my monitor input source to HDMI which is what I have my kvm/qemu guest outputting to via the passthru GTX 970. I had to specify the end value as 0x11 instead of just 11, the ddctool docs say either is valid however just 11 didn't work for me. ddctool setvcp 60 0x03 <--retus my monitor input source to DVI which is where my ubuntu host desktop is coected to. Simples!
So to automate the switching of my monitor based on when I start or stop the guest which has a GFX card passed through I used the Hooks feature of libvirt https://www.libvirt.org/hooks.html
Essentially libvirt hooks are bash or python scripts that are run automatically by libvirt, I'll let you do the reading up but I also find this (http://www.fragmentatioeeded.net/2...irt-hooks.html) article helpful.
Code:
sudo touch /etc/libvirt/hooks/qemu sudo chmod u+x /etc/libvirt/hooks/qemu
Code:
#!/bin/bash
GUEST=$1
STATUS=$2
POSITION=$3
case "$GUEST" in
"name-of-my guest" )
if [ "$STATUS" = "started" ]; then
ddctool setvcp 60 0x11
elif [ "$STATUS" = "stopped" ]; then
ddctool setvcp 60 0x03
fi
;;
esac
That's pretty much it!
برچسب:
نویسنده: استخدام کار