Skip to content

Instantly share code, notes, and snippets.

@aeharding
Created August 4, 2026 17:25
Show Gist options
  • Select an option

  • Save aeharding/4d08da9e77cf5d9521c09183904575f3 to your computer and use it in GitHub Desktop.

Select an option

Save aeharding/4d08da9e77cf5d9521c09183904575f3 to your computer and use it in GitHub Desktop.
toggle-monitor.sh
#!/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