Skip to content

Instantly share code, notes, and snippets.

@rosshadden
Created May 4, 2017 15:58
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save rosshadden/080cb46d8e504d024de7382144de668c to your computer and use it in GitHub Desktop.
Save rosshadden/080cb46d8e504d024de7382144de668c to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
numDisplays=$(xrandr --current | grep '\bconnected' | wc -l)
outputs="--output eDP1 --primary --mode 2880x1620 --pos 2880x0 --dpi 96 --scale 1x1"
xrandr --output HDMI1 --off
xrandr --output DP2 --off
if xrandr | grep "HDMI1 connected"; then
outputs+=" --output HDMI1 --auto --mode 1920x1080 --pos 0x0 --right-of eDP1 --scale 1.5x1.5"
fi
if xrandr | grep "DP2 connected"; then
outputs+=" --output DP2 --auto --mode 1920x1080 --pos 5760x0 --left-of eDP1 --scale 1.5x1.5"
fi
xrandr $outputs
if xrandr | grep "HDMI1 connected"; then
xrandr --output HDMI1 --pos 0x0
xrandr --output eDP1 --pos 2880x0
if xrandr | grep "DP2 connected"; then
xrandr --output DP2 --pos 5760x0
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment