Skip to content

Instantly share code, notes, and snippets.

@nma
Last active September 11, 2022 13:29
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save nma/8125f585f4111e1e55caee83c03b94a6 to your computer and use it in GitHub Desktop.
Save nma/8125f585f4111e1e55caee83c03b94a6 to your computer and use it in GitHub Desktop.
DPI Scaling Fix for Ubuntu on HiDPI 3840x2160 eDP1 with 1920x1080 External Monitor
#!/bin/bash
# Assumes that our global DPI default is for the Highest Resolution Monitor
# --scale 2x2: Our external monitor scale is 2x of our 4K monitor.
# --output <Name>: Just run xrandr without arguments to list device names.
# --mode: The supported mode of the --output monitor.
# --fb: 1920 * 2 x 1080 * 2 + 1080, or 3840x3240. Sets this monitors to fit this space.
# --pos: Set my external monitor's location starting at 0x0
xrandr --output HDMI2 --scale 2x2 --mode 1920x1080 --fb 3840x3240 --pos 0x0
# --scale 1x1: Our laptop monitor is equal to our global DPI setting.
# --pos 960x2160: Move our screen down so it does not overlap the external monitor. (1920 * 2 - 1920) / 2 x 1080 * 2, or 960x2160
xrandr --output eDP1 --scale 1x1 --pos 960x2160

Based on the contents http://blog.jamiek.it/2015/04/manually-fixing-multiple-screens-with.html

  • Set your Ubuntu to the highest DPI from the System Configurations
  • If not using Ubuntu, then you may need to configure based on instructions here and use a DPI calclator.
  • Please referer to the full blog post and give thanks to the OP.
  • This is just notes and a cached script for my personal laptop
  • My External Monitor (HDMI2) is Above my Laptop Screen (eDP1)
@nma
Copy link
Author

nma commented Sep 4, 2016

Note: There is a known isue of blurriness in the lower resolution monitor with this solution.

@forgetso
Copy link

This is a lifesaver. Thanks so much.

@Nek-
Copy link

Nek- commented Mar 30, 2019

Lifesaver indeed !

For information. XPS 2014 15" / Ubuntu 18.10

Here are the working commands:

xrandr --listmonitors # remplace HDMI-1 by maybe HDMI-1-1 and same for eDP
xrandr --output HDMI-1 --scale 2x2 --mode 1920x1080 --fb 3200x1800 --pos 0x0
xrandr --output eDP-1 --scale 1x1 --pos 960x2160

Not sure it's the best but it works.

[edit] Ubuntu 19.04 : just switch to wayland. It's working great, no command line needed. Thanks canonical.

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