UI scale with xrandr

ubuntu_logo_81x81Ubuntu 14.04 Unity desktop supports UI scaling for HD displays from a settings GUI. It is possible to scale the desktop using xrandr from the cmdline so that it is independent of the desktop environment you are using. This is particularly helpful for devices with smaller screens and is software controlled. This article will explain how to do it.

  1. Before you start, check the name of your display and current resolution. The commonest name for single monitor systems is LVDS1 but this may not be the case always. Run:
    $ xrandr
    Screen 0: minimum 1 x 1, current 1600 x 900, maximum 8192 x 8192
    Virtual1 connected primary 1600x900+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
    1600x900 60.0*+
    Virtual2 disconnected (normal left inverted right x axis y axis)
    Virtual3 disconnected (normal left inverted right x axis y axis)

    As you see above, in my case it’s a VM and the display name is Virtual1. The resolution is 1600×900.

  2. To change the resolution to 1920×1080, run the following command:
    $ xrandr --output Virtual1 --mode 1600x900 --panning 1920x1080 --scale 1.2x1.2
    output: display name
    mode: current display resolution shown in xrandr output in Step 1
    panning: the new resolution you want
    scale: scale factor for x and y

The scale factor is given by new x/y resolution divided by old x/y resolution. In the above example:

1920/1600 = 1.2 
1080/900 = 1.2

It’s advisable to scale by the same scale factor for x and y. The simplest choice is a higher resolution with the same aspect ratio. In the above example:

1920:1080 = 1600:900 = 16:9

If you do not choose the same aspect ratio, parts of the rendered screen will not fit your physical monitor and you’ll have to scroll to reach the end of the rendered screen. Your fonts might also look stretched and awkward.

The change is temporary and will go off after a reboot unless you add the command to a start-up script.

5 thoughts on “UI scale with xrandr”

  1. Thanks!

    I had some difficulties setting up UI scale with two monitors at the same time (basically I have a 1080p laptop with 13.3″ screen and 1080p 23″ screen and I wanted the 23″ screen to be 50% bigger, matching the dpi of the laptop), but after some trial and error I got it to work. Great success!

  2. I am trying to complete this task using a 4K display. What recommendations would you give for fixing the screen resolution for a 4K display using the xrandr command?

Leave a Reply

Your email address will not be published. Required fields are marked *