Skip to content

Instantly share code, notes, and snippets.

@DevNiall
Forked from wvengen/extend.sh
Last active February 14, 2017 05:37
Show Gist options
  • Save DevNiall/3dcd04f4e12b1e75910f53acb1b965cd to your computer and use it in GitHub Desktop.
Save DevNiall/3dcd04f4e12b1e75910f53acb1b965cd to your computer and use it in GitHub Desktop.
Extend non-HiDPI external display to right of HiDPI internal display using panning method
#!/bin/bash
# extend non-HiDPI external display on DP* to right of 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
SCALE=2
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_w=`xrandr | sed 's/^'"${INT}"' [^0-9]* \([0-9]\+\)x.*$/\1/p;d'`
int_h=`xrandr | sed 's/^'"${INT}"' [^0-9]* [0-9]\+x\([0-9]\+\).*$/\1/p;d'`
xrandr --output $INT --auto --output $EXT --auto --panning $(($ext_w*2))x$(($ext_h*2))+${int_w}+0 --scale ${SCALE}x${SCALE} --right-of $INT
@DevNiall
Copy link
Author

Using panning method to get around xserver bug where mouse does not reach the whole screen.

@kanishkdudeja
Copy link

Does your mouse flicker on the built in display?

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