Last active
December 15, 2015 19:48
-
-
Save zmpeg/5313531 to your computer and use it in GitHub Desktop.
extend desktop with xrandr. Usage: ./extend.sh [dir]
where [dir] is 'left' or 'right' or 'clone'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ -z "$1" ]; then | |
xrandr --output HDMI1 --mode 0x0 | |
else | |
RES=`xrandr | grep -A1 HDMI1 | tail -n1 | awk '{ print $1 }'` | |
echo "Detected HDMI1 with resolution ${RES}" | |
if [ "$1" == "right" ] || [ "$1" == "left" ]; then | |
echo "Extending HDMI1 to the {$1} of eDP1" | |
xrandr --output HDMI1 --mode $RES | |
sleep 1 | |
xrandr --output HDMI1 --$1-of eDP1 | |
else | |
if [[ "$1" == "clone" ]]; then | |
echo "Cloning eDP1 onto HDMI1" | |
xrandr --output HDMI1 --mode $RES | |
sleep 1 | |
xrandr --output HDMI1 --same-as eDP1 | |
else | |
if [[ "$1" == "up" ]]; then | |
echo "Extending HDMI1 above eDP1" | |
xrandr --output HDMI1 --mode $RES | |
sleep 1 | |
xrandr --output HDMI1 --above eDP1 | |
else | |
echo "Usage: ./extend.sh [dir]" | |
echo "where [dir] is 'left' or 'right' or 'clone'" | |
fi | |
fi | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment