Created
August 4, 2026 17:25
-
-
Save aeharding/4d08da9e77cf5d9521c09183904575f3 to your computer and use it in GitHub Desktop.
toggle-monitor.sh
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
| #!/bin/bash | |
| # toggle-monitor.sh | |
| # Toggle Display 1 between USB-C (0x19) and DisplayPort (0x0f) | |
| DISPLAY_NUM=1 | |
| # Get current input (last field from terse output) | |
| current=$(ddcutil --display 1 getvcp 60 --terse | awk '{print $NF}') | |
| if [ "$current" == "x0f" ]; then | |
| # Currently DisplayPort → switch to USB-C | |
| ddcutil --display 1 setvcp 60 0x19 | |
| echo "Display 1: switched from DisplayPort → USB-C" | |
| else | |
| # Currently USB-C (x19) or anything else → switch to DisplayPort | |
| ddcutil --display 1 setvcp 60 0x0f | |
| echo "Display 1: switched to DisplayPort" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment