1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
#!/bin/sh set -e temp="$(mktemp)" xrandr -q > "$temp" awk ' BEGIN { printf "xrandr " } $2 == "connected" { what = $1 res = "" } /^ [0-9]/ && what != "" { printf "--output %s --mode %s ", what, $1 if (what == "LVDS1") printf "--same-as VGA1 " what ="" } END { printf "\n" } ' "$temp" | sh rm -f "$temp"