Skip to content

Instantly share code, notes, and snippets.

@fvdnabee
Created April 9, 2016 23:33
Show Gist options
  • Save fvdnabee/c0bdf2ba5de209b297c1b34f2e66a250 to your computer and use it in GitHub Desktop.
Save fvdnabee/c0bdf2ba5de209b297c1b34f2e66a250 to your computer and use it in GitHub Desktop.
Shell script with xrandr for configuring displays at home or at work
#!/bin/sh
# This script will automatically configure my screen outputs depending on the
# outputs that are detected as connected by xrandr
# if both VGA1 and HDMI1 connected -> HDMI1 left of VGA1
# else if HMD1 connected and VGA1 not connected -> HDMI1 above internal display
# else -> just use internal display
if (xrandr | grep "HDMI1 connected") && (xrandr | grep "VGA1 connected"); then
# turn off internal screen:
xrandr --output LVDS1 --off
xrandr --output VGA1 --auto
xrandr --output HDMI1 --auto
echo "test"
xrandr --output HDMI1 --left-of VGA1
elif (xrandr | grep "HDMI1 connected") && (xrandr | grep "VGA1 disconnected"); then
xrandr --output VGA1 --off
xrandr --output LVDS1 --auto --output HDMI1 --auto
xrandr --output HDMI1 --above LVDS1
elif (xrandr | grep "HDMI1 disconnected") && (xrandr | grep "VGA1 connected"); then
xrandr --output HDMI1 --off
xrandr --output LVDS1 --auto --output VGA1 --auto
xrandr --output VGA1 --above LVDS1
else
xrandr --output LVDS1 --auto
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment