Customize default desktop environment settings for Gnome-centric Linux distributions

gnome-logoSome of you are probably wondering why would you want to spend your time fiddling with default desktop environment settings customization, when you can easily customize everything to your liking inside you own user account? Most probably you'd want to do this when you're re-mastering your favorite Linux distribution using tools like OS4 system imager (fork of the now discontinued Remastersys) or Relinux. In this article I'll show you how to handle this task elegantly using GSettings vendor overrides.

Introduction

First some background. GSettings provides a convenient API for storing and retrieving application settings, similar to system registry inside one of the popular proprietary operating system. Applications can define key/value pairs their application is using by installing .gschema.xml files, and then use GSettings API to manipulate the values. GSettings also provides mechanisms for distribution vendors to override default key/value pairs for specific applications by using .gschema.override files.

Pick the right schema file

First thing we need to do is picking the key/value pair which controls the setting whose defaults we want to modify. We do this using command line tools like "gsettings list-schemas" or "gsettings list-recursively" or using GUI tools like "dconf-editor". For the sake of simplicity and to better illustrate this process, in this article I'll use dconf-editor. On a Debian based distributions like Ubuntu we will find dconf-editor inside dconf-tools package:

sudo apt-get install dconf-tools

Now that we have all the tools lets imagine we want to change default fonts our Gnome-centric desktop environment like Gnome 3, Unity or Cinnamon is using. Using dconf-editor we can edit settings for current user account, but most importantly find GSettings schemas and key/value pairs we're interested in:

  • org.gnome.desktop.interface
    • font-name
    • document-font-name
    • monospace-font-name
  • org.gnome.desktop.wm.preferences
    • titlebar-font

Here's screenshot displaying one section of org.gnome.desktop.interface schema inside dconf-editor:

dconf-editor

Create .gschema.override file

Now when we have all of the information we can use our favorite editor to create the .gschema.override file:

sudo nano /usr/share/glib-2.0/schemas/60_our-own.gschema.override

The 60 is override priority, here I usually use 60 because most Linux distribution vendors use priority of 50 or less. Now we place following inside that file:

1
2
3
4
5
6
7
[org.gnome.desktop.interface]
font-name='Ubuntu 12'
document-font-name='Sans 12'
monospace-font-name='Ubuntu Mono 14'
 
[org.gnome.desktop.wm.preferences]
titlebar-font='Ubuntu Bold 12'

We exit and save using Ctrl^X and then compile GSettings schemas to reflect our changes like this:

sudo glib-compile-schemas /usr/share/glib-2.0/schemas/

After system restart desktop environment for all new users and existing users who haven't changed desktop environment fonts will use fonts we have specified inside our .gschema.override file. This way we can easily tweak almost every aspect of our desktop environment interface, and in the end easily create our own flavor of the Linux distro using remastersys-like tools. That's what I call flexible operating system, don't you agree?

DevGenii

E-commerce is a breeze with Magento Certified Developer Plus & Zend Certified PHP Engineer nearby. Get in touch!

Leave a Reply

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