Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # If an external monitor is connected, place it with xrandr
- # Adapted from: http://www.thinkwiki.org/wiki/Xorg_RandR_1.2#Now_automate_it_on_login
- ###### CHANGE THESE
- # External output may be "VGA" or "VGA-0" or "DVI-0" or "TMDS-1"
- EXTERNAL_OUTPUT="VGA1"
- INTERNAL_OUTPUT="LVDS1"
- # Resolution for the external monitor
- EXTERNAL_RES="1920x1080"
- # EXTERNAL_LOCATION may be one of: left, right, above, or below
- EXTERNAL_LOCATION="right"
- ###### DON'T CHANGE THESE
- case "$EXTERNAL_LOCATION" in
- left|LEFT)
- EXTERNAL_LOCATION="--left-of $INTERNAL_OUTPUT"
- ;;
- right|RIGHT)
- EXTERNAL_LOCATION="--right-of $INTERNAL_OUTPUT"
- ;;
- top|TOP|above|ABOVE)
- EXTERNAL_LOCATION="--above $INTERNAL_OUTPUT"
- ;;
- bottom|BOTTOM|below|BELOW)
- EXTERNAL_LOCATION="--below $INTERNAL_OUTPUT"
- ;;
- *)
- EXTERNAL_LOCATION="--left-of $INTERNAL_OUTPUT"
- ;;
- esac
- xrandr |grep $EXTERNAL_OUTPUT | grep " connected "
- if [ $? -eq 0 ]; then
- xrandr --output $INTERNAL_OUTPUT --off --output $EXTERNAL_OUTPUT --auto $EXTERNAL_LOCATION -s $EXTERNAL_RES
- # Alternative command in case of trouble:
- # (sleep 2; xrandr --output $INTERNAL_OUTPUT --auto --output $EXTERNAL_OUTPUT --auto $EXTERNAL_LOCATION) &
- else
- xrandr --output $INTERNAL_OUTPUT --auto --output $EXTERNAL_OUTPUT --off
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement