Skip to content

Instantly share code, notes, and snippets.

@brokenpylons
Created May 31, 2018 14:17
Show Gist options
  • Select an option

  • Save brokenpylons/d8522bfb7aef0e61d6b53fc99e9844dd to your computer and use it in GitHub Desktop.

Select an option

Save brokenpylons/d8522bfb7aef0e61d6b53fc99e9844dd to your computer and use it in GitHub Desktop.
#!/bin/bash
in='LVDS1'
ext='HDMI1'
#X server arguments
eval set -- $(pgrep -a X)
while (( $# > 0 ))
do
# Set display number
if [[ $1 =~ :[[:digit:]](.[[:digit:]])? ]]
then
export DISPLAY="$1"
fi
# Set xauth cookie file location
if [[ $1 = '-auth' ]]
then
export XAUTHORITY="$2"
fi
shift
done
if xrandr | grep "$ext connected"
then
# xrandr --output $in --auto --primary --output $ext --auto --right-of $in
xrandr --output $ext --auto --primary --output $in --off
else
xrandr --output $in --auto --output $ext --off
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment