DDC

It can be useful to call ddc functions from terminal for ease of adjustment of the monitor brightness and colour.

ddccontrol -p -c -d can be used to show the possible controls and it can also edit them.

DDC can be found with with VGA, Displayport and HDMI. There are other methods, depending on the display:

For extra speed it is possible to script DDC directly with the i2c binaries, beware warning in i2c manual about device damage though, and select the desired bus if different.

ddc 16
get bright
ddc 16 0
set bright
ddc 18
get contrast
ddc 18 0
set contrast
ddc () {
	SYSI2CBUS=`grep -l "^i915 gmbus dpb$" /sys/bus/i2c/devices/i2c-?/name` || \
		{ >&2 echo could not find display; return 1; } 
	I2CBUS="${SYSI2CBUS:25:1}"
	DDC=0x37

	if test ${#} -eq 2
	then
		C1=( 0x3 $(( ${1} + 0 )) $(( ${2} / 256 )) $(( ${2} % 256 )) )
	elif test ${#} -eq 1
	then
		C1=( 0x1 $(( ${1} + 0 )) )
	else
		>&2 echo syntax is ddc control_number_octet [new_value_octet]
		return
	fi
	LEN=$(( 0x80 | ${#C1[@]} ))
	C2=(0x51 $LEN "${C1[@]}")
	XOR=$(( $DDC << 1))

	for N in "${C2[@]}"
	do
		XOR=$(( $XOR ^ $N ))
	done

	/usr/sbin/i2cset -y $I2CBUS $DDC 0x00 "${C2[@]}" 0x`printf %x $XOR` i
	if test ${#C1[@]} = 2
	then
		N1=`/usr/sbin/i2cdump -y $I2CBUS $DDC i`
		VALUES=`echo "${N1}" | tail -n +2 | cut -c4-51 | sed -s "s/ / 0x/g"`
		ARRAY=( ${VALUES} )
		XOR=$(( 0x50 ))
		LEN=$(( ( ${ARRAY[1]} & 0x7F ) + 2))
		for N in `seq 0 $LEN`
		do
			XOR=$(( $XOR ^ ${ARRAY[$N]} ))
		done
		if test 0 -eq $XOR
		then
			echo max $(( ${ARRAY[6]} * 256 + ${ARRAY[7]} ))
			echo current $(( ${ARRAY[8]} * 256 + ${ARRAY[9]} ))
		fi
	fi
}