Skip to content

Instantly share code, notes, and snippets.

@Munsio
Created May 28, 2021 22:29
Show Gist options
  • Save Munsio/eaf93e48edcffb57827a8d35284167b8 to your computer and use it in GitHub Desktop.
Save Munsio/eaf93e48edcffb57827a8d35284167b8 to your computer and use it in GitHub Desktop.
Small helper script to diff the probe output of "ddccontrol - d"
#!/bin/bash
Help() {
# Display Help
echo "DDCDiff is a tool to help finding the manual changes while querieing the monitor."
echo
echo "Syntax: ./ddcdiff.sh [dev]"
echo "options:"
echo "dev: device, e.g. ./ddcdiff.sh dev:/dev/i2c-0"
echo "h : Print this Help."
echo
}
Probe() {
# Probe function
echo "Probing current state..."
CURRENT=$(ddccontrol -d $DEVICE)
echo "Now make your changes and press any key to continue"
read -n 1 -s
echo "Probing changed state..."
CHANGED=$(ddccontrol -d $DEVICE)
echo "Diffing output"
diff <( echo "$CURRENT" ) <( echo "$CHANGED" )
}
# Get the options
while getopts ":h" option; do
case $option in
h) # display Help
Help
exit;;
\?) # incorrect option
echo "Error: Invalid option"
exit;;
esac
done
DEVICE=$1
if [ -z $DEVICE ]; then
DEVICE="-p"
fi
while :
do
echo "1. Probe"
echo "2. Quit"
# echo -n "Type 1 or 2 or 3 :"
read -n 1 -s a
printf "\n"
case $a in
1* ) Probe;;
2* ) exit 0;;
* ) echo "Try again.";;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment