Skip to content

Instantly share code, notes, and snippets.

@pgericson
Last active August 29, 2015 14:18
Show Gist options
  • Save pgericson/6e6a17251e0dda33646e to your computer and use it in GitHub Desktop.
Save pgericson/6e6a17251e0dda33646e to your computer and use it in GitHub Desktop.
auto config multimonitor setup for i3
#!/bin/bash
echo 'Monitor-Auto-Setup script is starting...'
## this should be launched from e.g. ~/.i3/config file.
## this is a setup with one laptop LVDS1 and 2 monitors, one HDMI and one VGA.
displays="$(xrandr -q)"
if [[ $displays =~ VGA[0-9][[:space:]]connected && $displays =~ HDMI[0-9][[:space:]]connected ]]; then
echo '=== LAPTOP IS PROBABLY DOCKED w/ TWO DISPLAYS ==='
xrandr --verbose --output LVDS1 --off;
xrandr --verbose --output VGA1 --auto;
xrandr --verbose --output VGA2 --auto;
xrandr --verbose --output HDMI1 --auto --right-of VGA2;
xrandr --verbose --output HDMI1 --auto --right-of VGA1;
elif [[ $displays =~ VGA[0-9][[:space:]]connected ]]; then
echo '=== LAPTOP IS PROBABLY DOCKED w/ ONE vga DISPLAYS ==='
xrandr --verbose --output LVDS1 --auto --primary;
xrandr --verbose --output VGA1 --auto --left-of LVDS1;
xrandr --verbose --output VGA2 --auto --left-of LVDS1;
xrandr --verbose --output HDMI1 --off;
elif [[ $displays =~ HDMI[0-9][[:space:]]connected ]]; then
echo '=== LAPTOP IS PROBABLY DOCKED w/ ONE hdmi DISPLAYS ==='
xrandr --verbose --output LVDS1 --auto --primary;
xrandr --verbose --output VGA1 --off;
xrandr --verbose --output VGA2 --off;
xrandr --verbose --output HDMI1 --auto --right-of LVDS1;
else
echo '=== LAPTOP IS NOT DOCKED ==='
xrandr --verbose --output LVDS1 --auto --primary;
fi
echo 'Monitor-Auto-Setup script has finished'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment