Created
January 11, 2020 23:34
-
-
Save socketbox/6aba5ebb1dfff3bff5ee10c5431cbe9b to your computer and use it in GitHub Desktop.
Toggle monitor input from keyboard in linux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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