Skip to content

Instantly share code, notes, and snippets.

@jsonfry
Forked from bitjockey42/extend.sh
Last active April 11, 2017 08:20
Show Gist options
  • Save jsonfry/7e5931b8174374b3c58b454265c48635 to your computer and use it in GitHub Desktop.
Save jsonfry/7e5931b8174374b3c58b454265c48635 to your computer and use it in GitHub Desktop.
Extend non-HiDPI external display to left of HiDPI internal display
#!/bin/sh
# extend non-HiDPI external display on DP* left of a HiDPI internal display eDP*
# see also https://wiki.archlinux.org/index.php/HiDPI
# you may run into https://bugs.freedesktop.org/show_bug.cgi?id=39949
# https://bugs.launchpad.net/ubuntu/+source/xorg-server/+bug/883319
# Original version from: https://gist.github.com/wvengen/178642bbc8236c1bdb67
EXT=`xrandr --current | sed 's/^\(.*\) connected.*$/\1/p;d' | grep -v ^eDP | head -n 1`
INT=`xrandr --current | sed 's/^\(.*\) connected.*$/\1/p;d' | grep -v ^DP | head -n 1`
ext_w=`xrandr | sed 's/^'"${EXT}"' [^0-9]* \([0-9]\+\)x.*$/\1/p;d'`
ext_h=`xrandr | sed 's/^'"${EXT}"' [^0-9]* [0-9]\+x\([0-9]\+\).*$/\1/p;d'`
int_h=`xrandr | sed 's/^'"${INT}"' [^0-9]* [0-9]\+x\([0-9]\+\).*$/\1/p;d'`
int_w=`xrandr | sed 's/^'"${INT}"' [^0-9]* \([0-9]\+\)x.*$/\1/p;d'`
off_w=`echo $(( ($int_w-$ext_w)/2 )) | sed 's/^-//'`
off_h=$(( $((ext_h/2)) - $((int_h/2)) ))
xrandr --output "${INT}" --auto --pos ${ext_w}x${off_h} --scale 1x1 --output "${EXT}" --auto --scale 2x2 --pos 0x0
@jsonfry
Copy link
Author

jsonfry commented Apr 11, 2017

Internal hdpi monitor sits in the center right of the non hdpi monitor
out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment