CURRENT_OUTPUT=`ddccontrol -r 0x60 dev:/dev/i2c-5 | sed -n 's|.*0x60: +/\([0-9]\+\)/15.*|\1|p'` if [ $CURRENT_OUTPUT = 3 ] then # switch to first input ddccontrol -r 0x60 -w 15 dev:/dev/i2c-5 else # switch to second input ddccontrol -r 0x60 -w 3 dev:/dev/i2c-5 fi