Last active
November 2, 2022 10:09
-
-
Save rn0/e8be0a51e834f0a4e73faf245ec9c762 to your computer and use it in GitHub Desktop.
This file contains 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 | |
set -o nounset | |
set -o errexit | |
[[ "$EUID" -eq 0 ]] || exec sudo /bin/bash -c "$(printf '%q ' "$BASH_SOURCE" "$@")" | |
declare -A source=( [0x0f]="DP" [0x11]="HDMI" ) | |
declare -A inputMap=( [0x0f]=0x11 [0x11]=0x0f ) | |
monitor1=$(ddcutil getvcp --display 1 60 | sed -n "s/.*(sl=\(.*\))/\1/p") | |
monitor2=$(ddcutil getvcp --display 2 60 | sed -n "s/.*(sl=\(.*\))/\1/p") | |
echo "Monitor 1 = ${source[$monitor1]}; Monitor 2 = ${source[$monitor2]}" | |
monitor1NewInput=${inputMap[$monitor1]} | |
monitor2NewInput=${inputMap[$monitor2]} | |
echo "Monitor 1 = ${source[$monitor1NewInput]}; Monitor 2 = ${source[$monitor2NewInput]}" | |
ddcutil setvcp --display 1 60 $monitor1NewInput | |
ddcutil setvcp --display 2 60 $monitor2NewInput |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment