Skip to content

Instantly share code, notes, and snippets.

@socketbox
Created January 11, 2020 23:34
Show Gist options
  • Save socketbox/6aba5ebb1dfff3bff5ee10c5431cbe9b to your computer and use it in GitHub Desktop.
Save socketbox/6aba5ebb1dfff3bff5ee10c5431cbe9b to your computer and use it in GitHub Desktop.
Toggle monitor input from keyboard in linux
#!/usr/bin/env bash
#TODO: call ddcutil detect and parse output for actual devices; only constants should be VCP code and vars
# related to ddcutil
BUS_FLAG="-b"
I2C_ID=5
CMD="ddcutil"
GETTER=getvcp
SETTER=setvcp
DP=15
HDMI=17
NOCHCK="--nodetect --noverify"
VCP=0x60
function main()
{
getout=$( sudo $CMD $NOCHCK $BUS_FLAG $I2C_ID $GETTER $VCP )
if [[ $getout == *DisplayPort* ]]
then
eval sudo $CMD $NOCHCK $BUS_FLAG $I2C_ID $SETTER $VCP $HDMI
elif [[ $getout == *HDMI* ]]
then
eval sudo $CMD $NOCHCK $BUS_FLAG $I2C_ID $SETTER $VCP $DP
fi
}
main
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment