#!/usr/bin/env bash MON=1 # Primary monitor DP="0x0f" HDMI1="0x11" HDMI2="0x12" ### CURR_INPUT="" function toggle { get_input if [[ ${CURR_INPUT} == ${DP} ]]; then set_input ${HDMI1} elif [[ ${CURR_INPUT} == ${HDMI1} ]]; then set_input ${DP} fi } function set_input { ddcutil setvcp -d ${MON} 60 ${1} } function get_input { CURR_INPUT="0$(ddcutil getvcp -d ${MON} 60 -t | cut -d' ' -f4)" } if [ $@ ]; then for arg in "$@"; do shift; case $arg in "--dp") set_input ${DP} ;; "--hdmi1") set_input ${HDMI1} ;; "--hdmi2") set_input ${HDMI2} ;; "-h") echo "Usage: $0 [--dp|--hdmi1|--hdmi2]" ;; esac done else toggle fi