Last active
May 30, 2017 20:12
-
-
Save mykiwi/ce237cfae34fa8d3d06952a028c32681 to your computer and use it in GitHub Desktop.
Gnome & Hidp - Multiple displays
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 | |
# https://wiki.archlinux.org/index.php/HiDPI#Multiple_displays | |
# 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_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'` | |
scale_w=`gsettings get org.gnome.desktop.interface scaling-factor | cut -d' ' -f2` | |
scale_h=${scale_w} | |
ext_to_w=`expr ${ext_w} \* ${scale_w}` | |
ext_to_h=`expr ${ext_h} \* ${scale_h}` | |
# Generically if your HiDPI monitor is AxB pixels and your regular monitor is CxD and you are scaling by [ExF], the commandline for right-of is: | |
# xrandr --output eDP-1 --auto --output HDMI-1 --auto --panning [C*E]x[D*F]+[A]+0 --scale [E]x[F] --right-of eDP-1 | |
xrandr --output "${INT}" --auto --output "${EXT}" --auto --scale ${scale_w}x${scale_h} --right-of "${INT}" |
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 | |
set -x | |
EXTERNAL_OUTPUT_LEFT="DP-1-8" | |
EXTERNAL_OUTPUT_RIGHT="DP-1-1" | |
#EXTERNAL_SIZE="--mode 3840x2160 --scale 1x1" | |
EXTERNAL_SIZE="--mode 3840x2160 --scale 0.75x0.75" | |
# EXTERNAL_SIZE="--mode 2560x1440 --scale 1x1" | |
INTERNAL_OUTPUT="eDP-1" | |
INTERNAL_SIZE="--mode 1920x1080 --scale 1x1" | |
# INTERNAL_SIZE="--mode 2560x1440 --scale 1x1" | |
xrandr | grep "$EXTERNAL_OUTPUT_RIGHT " -A 0 | grep " connected " | |
if [ $? -eq 0 ]; then | |
xrandr --output $INTERNAL_OUTPUT --off --output $EXTERNAL_OUTPUT_LEFT $EXTERNAL_SIZE --primary --output $EXTERNAL_OUTPUT_RIGHT $EXTERNAL_SIZE --right-of $EXTERNAL_OUTPUT_LEFT | |
exit 0 | |
fi | |
xrandr --output $INTERNAL_OUTPUT $INTERNAL_SIZE --output $EXTERNAL_OUTPUT_LEFT --off --output $EXTERNAL_OUTPUT_RIGHT --off |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment