Skip to content

Instantly share code, notes, and snippets.

@Eyenseo
Forked from wvengen/extend.sh
Last active August 29, 2015 14:11
Show Gist options
  • Save Eyenseo/d8059608424f95d63632 to your computer and use it in GitHub Desktop.
Save Eyenseo/d8059608424f95d63632 to your computer and use it in GitHub Desktop.
#!/bin/sh
# extend non-HiDPI external display on DP1 above HiDPI internal display eDP1
# 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
ext_w=`xrandr | sed 's/^DP1 [^0-9]* \([0-9]\+\)x.*$/\1/p;d'`
ext_h=`xrandr | sed 's/^DP1 [^0-9]* [0-9]\+x\([0-9]\+\).*$/\1/p;d'`
int_w=`xrandr | sed 's/^eDP1 [^0-9]* \([0-9]\+\)x.*$/\1/p;d'`
int_h=`xrandr | sed 's/^eDP1 [^0-9]* [0-9]\+x\([0-9]\+\).*$/\1/p;d'`
off_w=`echo $(( ($int_w-$ext_w)/2 )) | sed 's/^-//'`
xrandr --output eDP1 --auto --pos ${off_w}x${ext_h} --output DP1 --auto --scale-from ${int_w}x${int_h} --pos 0x0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment