Skip to content

Instantly share code, notes, and snippets.

@jackdpeterson
Created April 4, 2018 18:05
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jackdpeterson/1d9500cb9c87c4bbcf4bece8942ffc5e to your computer and use it in GitHub Desktop.
Save jackdpeterson/1d9500cb9c87c4bbcf4bece8942ffc5e to your computer and use it in GitHub Desktop.
Ubuntu 18.04 - Mixed DPI with 4k Laptop monitor (HiDPI), and two LoDPI monitors (27", 21")
#!/bin/bash
echo "setting frame buffer" &&
xrandr --fb 12800x2880 &&
echo "setting laptop monitor" &&
xrandr --output eDP-1-1 --mode 3840x2160 --rate 60 --primary&&
echo "setting 27 inch monitor" &&
xrandr --output DP-0.2 --mode 2560x1440 --scale-from 5120x2880 --panning 5120x2880+3840+0 --right-of eDP-1-1 &&
echo "setting the samsung monitor" &&
xrandr --output DP-0.1 --mode 1920x1080 --scale-from 3840x2160 --panning 3840x2160+8960+0 --right-of DP-0.2&&
echo "setting global scaling to 2x" &&
gsettings set org.gnome.desktop.interface scaling-factor 2
@AGlass0fMilk
Copy link

Thanks for this! If you're on a Dell XPS 15 w/ 4k display and trying to use lower-res external displays with a TB16 dock, check out my gist that automatically runs a script like this when you plug in your dock:
https://gist.github.com/AGlass0fMilk/16672f82439a6bc601d80632b99f6179

@superhawk610
Copy link

superhawk610 commented Feb 20, 2019

Thanks so much for this! I made a few tweaks to fit my setup; I've got a 4K monitor in the middle and a rotated monitor on the right. I removed --right-of as it didn't seem to do much.

#!/bin/bash
# Devices
LEFT="DP-3"
MID="DP-0"
RIGHT="HDMI-0"

# Modes
_4K=3840x2160
_4Kr=2160x3840
_1080P=1920x1080

echo "setting frame buffer" &&
xrandr --fb 9840x3840 &&
echo "configuring LEFT" &&
xrandr --output $LEFT --mode $_1080P --scale-from $_4K --panning $_4K &&
echo "configuring MID" &&
xrandr --output $MID --mode $_4K --panning "$_4K+3840+0" --primary &&
echo "configuring RIGHT" &&
xrandr --output $RIGHT --mode $_1080P --scale-from $_4K --panning "$_4Kr+7680+0" --rotate right &&
echo "setting global scale factor" &&
gsettings set org.gnome.desktop.interface scaling-factor 2

BONUS: if you want to run this on boot, just link it to your Xsession config:

sudo ln -s ~/scripts/dpi.sh /etc/X11/Xsession.d/45dpi

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