Converting Brainstorms to Blogs

Monday, December 10, 2012

Changing DPI setting on Gnome 3.4

The following post outlines the steps I took to change the hard-coded DPI of 96 on Gnome 3.4 to my desired DPI.

The problem and why one would want to go through the trouble

My monitor (an IBM T221) has an extreme resolution... 3840x2400 pixels on 22 inches. This means that by default all text is extremely small, and so are icons, buttons, scroll-bars etc. In Gnome 3 and also in Unity text can be "scaled" to be larger, either through the accessibility options or through other configuration settings. However, that does not always help when it comes to buttons, titlebars etc. It also often messes up the entire layout of applications, and will require the user to constantly resize windows.

In Gnome 2 the DPI value could be changed, through the dconf editor if I remember correctly, and everything looked great; but in Gnome 3 this is not possible anymore. The DPI value is hard-coded and I do not know of any plugins that could fix this.

Therefore I spend a couple of days looking for a solution which would involve hacking the source code. Read on if you are having similar issues and want to change your DPI setting as well.

System Setup

The following instructions were performed on a fresh live-cd of Ubuntu 12.04. I am not a big fan of the Unity desktop, and thus installed Gnome-Shell, logged out, changed my session to Gnome and logged back in (on the live-cd the username is "ubuntu" and the password is blank).

I am not sure if the instructions would work for the Unity desktop as well without installing Gnome-Shell first; to be on the safe side, just install Gnome-Shell, it's a pretty neat desktop anyway.

Let's start hacking

The gnome-settings-daemon will have to be compiled from source code. This requires a few things to be setup.

Most of the tips for setting this up were taken from this page:

Get your environment ready

Open Terminal (on Gnome 3, press the super-key or point to the top left of the screen and type Terminal).

Once Terminal is open, use the command-line to install build-essential and checkinstall. Not sure if this is absolutely necessary, buy can't hurt either:
sudo apt-get install build-essential checkinstall

Also install apt-file, which will make it easier to find dependencies that we may need when the configure command complains:
sudo apt-get install apt-file

Use the folder /usr/local/src for all your work, but set up the right permissions to avoid any problems (replace <user> with your username):
cd /usr/local/src
sudo chown <user> .
chmod 755 .

Install all the dependencies for the gnome-settings-daemon that we will install. Just copy and paste this line into the Terminal, it should just work. The list was taken from the "gnome-settings-daemon_3.4.1-0ubuntu1.dsc" file on
sudo apt-get install cdbs debhelper gnome-pkg-tools dh-autoreconf autotools-dev intltool libdbus-glib-1-dev libglib2.0-dev libgtk-3-dev libgconf2-dev libnotify-dev libxt-dev libxi-dev libfontconfig1-dev libxext-dev libx11-dev libxtst-dev libgnomekbd-dev libxklavier-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev gsettings-desktop-schemas-dev libgnome-desktop-3-dev libpulse-dev libcanberra-gtk3-dev libpolkit-gobject-1-dev libappindicator3-dev hwdata libupower-glib-dev libcolord-dev liblcms2-dev libnss3-dev libgudev-1.0-dev libwacom-dev xserver-xorg-input-wacom

Get the gnome-settings-deamon source code and extract it:
tar xvf gnome-settings-daemon_3.4.1.orig.tar.xz

Hack the DPI Setting

Now it's time to edit the DPI setting. To do so, cd into the directory where gsd-xsettings-manager.c is and search for the DPI value (which is 96 originally). On my screen with a 3840x2400 resolution a DPI value of 160 looks good, but on smaller resolutions you should definitely use a smaller value. 120 might be a good start.
cd gnome-settings-daemon-3.4.1/plugins/xsettings
nano gsd-xsettings-manager.c

Once you have the file open in nano, look for #define DPI_FALLBACK 96, which is right after a long long comment. Here change the value from 96 to the one you desire, press Ctrl+O to save and then Ctrl+X to exit nano.

Now go back into the extracted directory and run the configure command:
cd /usr/local/src/gnome-settings-daemon-3.4.1

At this point the configure script may complain about missing libraries. In my case it was cups-config. In order to find the package name and install it, I used apt-file:
apt-file search cups-config

The result from apt-file gives a list of possible packages that might correspond to the missing one, in my case it was libcups2-dev, so I installed it:
sudo apt-get install libcups2-dev

Once all dependencies are installed, we can run the configure command again:

Compile the Code

Once all dependencies are installed, it's time to compile gnome-settings-daemon:

Now my approach differs from the post on the Ubuntu site--instead of installing the entire package, I only replaced the new file with the existing one on my system. I tried to install the complete package at some point, but it caused problems afterwards. Anyway, to do this, I made a backup of the old file, and then copied the new one into the directory where it belongs:
cd /usr/lib/gnome-settings-daemon-3.0/
sudo mv
sudo cp /usr/local/src/gnome-settings-daemon-3.4.1/plugins/xsettings/.libs/ .

And finally...

After this I closed all programs, held my breath, and logged out and back in. In my case, it worked... I hope it will work for you as well.

Reverting this Hack

If things went wrong, one simply has to replace the new with the old one. This can be done from the terminal, either in Gnome or from a TTY which can be reached by holding down Ctrl and Alt and pressing F1:
cd /usr/lib/gnome-settings-daemon-3.0
sudo mv

Final Words

Please notice that not every application obeys to the DPI setting. Google Chrome as well as Chromium will for example still have tiny text for their tabs. As far as I know, this is due to the fact that these applications also hard-coded the font sizes somehow.
Also icons will not necessarily scale; there are other how-tos and tutorials online that explain how to make these larger.

I hope this was helpful for anybody out there looking for a higher DPI setting,



  1. Man, you make my day! Thanks a lot for this solution.

  2. Doesn't work for me in Ubuntu 13.10 with the latest gnome-settings-daemon


Blog Archive