GNOME x11 fractional scaling

I have used GNOME for 2 years but now forced to use KDE Plasma since it uses DPI value from .Xresources. In this article I will describe how to achieve true fractional scaling under GNOME. Note that this is just an experiment; it may not be suitable for everyday use.

1. Recompile gnome-settings-daemon

In gnome-settings-daemon located DPI value. By default it is 96. If content too small, you need to increase this value: try values 120 (125%), 144 (150%) etc. For me, the ideal option is 130.

  1. Clone gnome-settings-daemon
  2. Find and open file gnome-settings-daemon/plugins/xsettings/gsd-xsettings-manager.c
  3. Find the line with #define DPI_FALLBACK 96. Now it is 236. Replace 96 with optimal value
  4. According to README, build and install with following commands:
    mkdir build && cd build
    meson --prefix=/usr --sysconfdir=/etc .. && ninja
    sudo ninja install
  5. Reboot your computer

2. Configure theme

Note: not all themes displaying correctly after these changes. I’m using Materia Dark and I haven’t issues with it. Next actions will increase the shell font size, which also scales the shell itself.

First, open /usr/share/themes/YOUR_THEME/gnome-shell/gnome-shell.css. You will see something like this:

Change font-size value. For example, set it to 1.3em. Save file. Type alt+F2, type r and press enter.

You also may be need to scale calendar. To do this, add in the end of the file next code:

Type alt+F2, type r and press enter.

3. Configure title buttons size

You maybe also will want to increase size of title buttons. To do this open file ~/.config/gtk-3.0/gtk.css. Add at the end of the file next code:

button.titlebutton {
    min-height: 32px;
    min-width: 32px;
    padding: 0;
}

You can use your params instead of 32px.

Edit (21.07.20):
As lockscreen you can use gnome-screensaver. Just install it and launch. To make it start automatically with GNOME, add the following to your ~/.bash_profile :

if [ "$XDG_CURRENT_DESKTOP" == "GNOME" ]; then
    gnome-screensaver & disown
fi

This will prevent you from using GDM at all, you can use SDDM instead. Also note, that if GDM is running then you cannot use gnome-screensaver.

Conclusion

This scaling isn’t ideal, it has pros and cons. It doesn’t affect elements such as GDM, which is used as a lock screen. Perhaps I will continue my experiment and will periodically update the article. So, pros:

  • True x11 scaling
  • Does not consume more resources
  • Applications don’t get blurry, as happens with fractional scaling on Wayland

Cons:

  • You need to recompile gnome-settings-daemon after every update
  • GDM will still without changes
  • You need to edit theme; not all themes will be displayed correctly after all manipulations

If you have any questions/suggestions – be sure to write in the comments, or better write me a letter: [email protected]