Advertisement

How to Find and Change Screen DPI in Linux

The DPI value of a screen indicates how many dots per inch or pixels per inch it supports. As the resolution increases, the display density also increases. You may know what resolution your display has but you may have no idea what your screen's DPI is. It is important to find the proper DPI value in Linux. Setting it to an incorrect value will make controls and icons look blurry or small. In this article, we will see how to find the right value for your screen.

Advertisеment


In modern distros, the X server can automatically detect the right value. If the value is incorrect, you can calculate it manually and change it in your Linux desktop environment and for the X server globally.

Note: Not all Linux software looks okay in high-resolution mode yet. For example, LibreOffice supports HiDPI well, but does not come with a single icon theme which suits high-resolutions. The scaling factor of Mozilla Firefox also needs to be adjusted manually. Only the Cinnamon desktop environment has perfect DPI scaling support out-of-the-box.

Let's see how to find your DPI value in Linux.

Find the DPI value for your screen

To find the current DPI value of the screen used by Xserver, do the following.

  1. Open your favorite terminal emulator.
  2. Type or copy-paste the following command:
    xdpyinfo | grep -B 2 resolution

    The output will be something like this:Find Current Dpi Value

The line "resolution" shows the actual value.

If this value is not correct, you can calculate it yourself. Here is how.

How to calculate the right DPI value

To calculate the proper DPI value, do the following.

  1. Open your favorite terminal emulator
  2. Get your screen size in millimeters by running the command:
    xrandr | grep -w connected

    The output contains the physical display size in millimeters. In my case, it is 340mm x 190mm.Find Current Screen Size

  3. Convert it to centimeters. My values are 34 x 19.
  4. Convert centimeters to inches. Divide the values by 2.54. In my case, the values are as follows: 13.39in x 7.48in.
  5. Finally, divide your screen resolution values by inch values. In my case, the values are as follows:
    1920/13.39 = 143,390589993=~144.
    1080/7.48 = 144,385026738=~144.

That's it. For my screen, I need to use 144 as my DPI value. Let's see how to change it.

How to change the DPI value

Depending on the graphical desktop environment you are using, the procedure can be different. I'll review some common cases which will give you an idea of what to do.

No desktop environment/barebones window manager

If you are running a window manager without a full featured DE (for example, Fluxbox), you must create or modify the /home/your user name/.Xresources file and add the following line:

Xft.dpi: 144

Here and in all examples below, substitute the 144 portion with your actual DPI value.

If your .Xresources file is not processed, add the following line to your startup file (e.g. .xinitrc or some window manager-specific file)

xrdb -merge ~/.Xresources

Alternatively, you can try with the following line:

xrandr --dpi 144

However, xrandr may have issues with certain display drivers. Try and see if this works or not. In my case, this doesn't work.

Gnome 3

Open a new terminal window and execute the command:

gsettings set org.gnome.desktop.interface scaling-factor 2

The scaling-factor parameter allows only whole numbers to be set. 1 = 100%, 2 = 200% and so on.

Xfce

The DPI can be set to what you want under Settings - Appearance - Font.

Change Screen DPI Linux

For further reading, I recommend you to refer to this page. It is dedicated to Arch Linux, but the tips are common between all modern distros or can be easily adapted.

Support us

Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:

If you like this article, please share it using the buttons below. It won't take a lot from you, but it will help us grow. Thanks for your support!

Advertisеment

Author: Sergey Tkachenko

Sergey Tkachenko is a software developer who started Winaero back in 2011. On this blog, Sergey is writing about everything connected to Microsoft, Windows and popular software. Follow him on Telegram, Twitter, and YouTube.

2 thoughts on “How to Find and Change Screen DPI in Linux”

  1. Thanks!
    I change my display setup from time to time, but I can never remember where to find the appropriate setting. I would have NEVER expected it to be in the ‘Fonts’ section lol

Leave a Reply

Your email address will not be published.

css.php
Using Telegram? Subscribe to the blog channel!
Hello. Add your message here.