-
-
Save pointhi/2a078a8ac5cf1ce5f7f1f10a919b53fb to your computer and use it in GitHub Desktop.
Extend non-HiDPI external display left to HiDPI internal display
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/sh | |
# extend non-HiDPI external display on DP* on the left side of the HiDPI internal display eDP* | |
# | |
# run the script a second time if you get an error like: | |
# xrandr: specified screen 6400x2160 not large enough for output HDMI1 (5120x2880+0+0) | |
# | |
# 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'` | |
off_w=`echo $(( ($int_w-$ext_w)/2 )) | sed 's/^-//'` | |
pan_w=`echo $(( $ext_w*$SCALE )) | sed 's/^-//'` | |
pan_h=`echo $(( $ext_h*$SCALE )) | sed 's/^-//'` | |
full_w=`echo $(( $ext_w+$int_w )) | sed 's/^-//'` | |
if (( ext_h > int_h )); then | |
used_h=$ext_h | |
else | |
used_h=$int_h | |
fi | |
xrandr --output "${INT}" --auto --pos ${ext_w}x0 --output "${EXT}" --scale ${SCALE}x${SCALE} --auto --pos 0x0 --fb ${full_w}x${used_h} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment