GConf — GNOME under the hood
[ Monday, 2 July 2007, smalu ]
To put things short, Gconf is a system built in GNOME 2 which stores applications’ preferable configuration data as well as graphical environment variables in its own files (think: GNOME registry). I’d like you to get familiar with the Gconf tool’s functions, engineering, and usage with this article.
Author: Mikołaj Smal
The direct predecessor of the Gconf was Gnome-config. It was a very simple configuration system based on INI files. Such solution has lived up to its promises in case of small applications. Therefore Gconf was implemented in GNOME 1.4 already, but only in GNOME 2 it started to be used on a larger scale. Gconf’s inner structure resembles that of Windows Registry, albeit the similarity is rather little. Only the graphical interfaces of their key managers evince resemblance.
Engineering
All data is kept in XML files distributed within appropriate directories. First, the file /etc/gconf/gconf.xml.mandatory is read only for non root users by default. This file contains obligatory settings for all users. In other words, they cannot be altered or deleted. $(HOME)/.gconf is processed next (the $HOME enviroment defines a path to the user’s home directory) but this time its attributes embrace both read and write modes. Only at the end of the process, default values contained in the etc/gconf/gconf.xml.defaults file are taken into consideration. The default data, similarly to the mandatory data for common users, is retrieved in read-only mode. Its values can be changed by superusers only.
The Keys are divided into directories, but contrary to those found in “regedit”, they have intuitive names. It’s easy to guess that /apps contains application data, and /system keeps system data. Every Key has its own structure called a schema where it stores its short and full description, its default values, and types of the values (int, string, etc). All in all it is a sort of documentation, useful for IT administrators.
Text Mode Control
Gconftool is a text tool to manage Gconf system. It allows to retrieve the Keys, modify their values, delete them and set up new Key schemas. For example, to get (to retrieve) information on an icon theme, we can issue the command gconftool-2 -g /desktop/gnome/interface/icon_theme. We can change the background picture as well – gconftool-2 -t string -s /desktop/gnome/background/picture_filename /path/to/picture. Of course, there are a lot of options and possibilities, but to get them known better it is advisable to read the gconftool-2 manual (man gconftool-2).
Graphical Mode Control
Gconf-editor is a graphical wrapper to gconftool. Thanks to the “configuration editor” the Keys values can be easily changed without typing long commands in terminal sessions.
You will be able to make changes to mandatory and default values after running gconf-editor as a superuser or issueing command sudo gconf-editor. To perform this dangerous act (I do not recommend messing about with the default values too much), you’ll have to select either the “New mandatory settings window” from the File menu in the configuration editor (Ctrl+M will suffice) or to select the “New default settings window” (Ctrl+D).
Cheap tricks for GNOMEcs
Gconf-editor is able to modify the system’s behavior according to our demands as no other tool. The table below contains an interesting list of Keys, modifications to which could give exciting results.
| Key/Branch | description & suggestions |
|---|---|
| /apps/notification-daemon/popup_location | Alternative text placement. Available values: “top_left”,”top_right”,”bottom_left”, and “bottom_right” |
| /desktop/gnome/volume_manager/autoipod_command | this is the command that is executed automatically after an iPod (or noname brand) has been connected, the default is the Rhythmbox audio player. For example, it could be interesting to use it to synchronize data between the disk and a player. |
| /desktop/gnome/url-handlers/ | This branch stores “hyperlink catchers” (weird name, but it’s consistent with the tool’s function). For example, if /desktop/gnome/url-handlers/gg/command has its value set to gaim-url-handler "%s", then after clicking a hyperlink gg:2813235, the Gaim communicator will be opened and a talk window with the user with UIN 2813235 will be brought up. Every subbranch of a given branch needs to have three Keys – command, enabled (on or off), and needs_terminal (whether a command must be run in a terminal). |
| /apps/nautilus/desktop/computer_icon_visible | Defines whether the Computer icon should be placed on the Desktop. |
| /apps/nautilus/desktop/*_icon_visible | Similar meaning as the one descibed above. We need to replace the star characters with either “home” (home directory), “documents”, “network” or “trash”. |
| /apps/nautilus/desktop/computer_icon_name | Alternative name for the Computer icon. |
| apps/nautilus/desktop/*_icon_name | Similar meaning as the one descibed above. We need to replace the star characters with “home” (home directory), “documents”, “network” or “trash”. |
| /apps/nautilus/desktop/volumes_visible | Defines whether a device icon should be placed on the Desktop automatically. |
| /apps/nautilus/preferences/confirm_trash | If set to off, no confirmation dialog will be shown when placing a file in the trash. |
| /apps/nautilus/preferences/show_desktop | We can stop displaying icons on Desktop. :] |
| /apps/nautilus/icon_view/captions | Icon captions’ list visible on Desktop or in “show icon” mode. The number of captions depends on magnifying level. Available values are: “size”, “type”, “date_modified”, “date_changed”, “date_accessed”, “owner”, “group”, “permissions”, “octal_permissions”, and “mime_type”. |
| /apps/gnome-session/options/show_splash_screen | Setting it to off will stop the welcome screen to appear. |
| /apps/nautilus/preferences/executable_text_activation | What to do with executable text files when they’re activated (with one or double click). Available values: “launch” – run as a program, “ask” – run through dialog window, “display” – show as text files. |
| /apps/nautilus/preferences/desktop_is_home_dir | Determines whether Nautilus should use user’s home directory as a Desktop. If not, files will be stored in the ~/Desktop directory. |
| /apps/gnome-screenshot/include_border | Defining screenshots with window manager’s border. |
| /apps/gnome-screenshot/border_effect | Border effect added to the external parts of screeshots’ edges. With the help of the default GNOME tool. Available types: “shadow”, “none”, and “border”. |
Working Example
We will make use of Gconf at the end of the article. The small script below was written in the Bash shell scripting language. It needs the zenity and the scrot applications. The first one is delivered together with Ubuntu, but I had to download and install the second one (sudo apt-get install scrot). The Scrot is an excellent console application for captering screenshots, and the zenity is a handy suite of GTK widgets (small graphical modules). This script displays information on icon/GTK/Metacity themes, and information about the GTK/Metacity font, and then captures a screenshot.
#!/bin/bash
icons=`gconftool-2 -g /desktop/gnome/interface/icon_theme`
theme_gtk=`gconftool-2 -g /desktop/gnome/interface/gtk_theme`
theme_metacity=`gconftool-2 -g /apps/metacity/general/theme`
font_gtk=`gconftool-2 -g /desktop/gnome/interface/font_name`
font_meta=`gconftool-2 -g /apps/metacity/general/titlebar_font`
scrot %Y-%m-%d.png -q100 -d 1&
zenity --info --text "
icons: $icons
GTK theme: $theme_gtk
metacity theme: $theme_metacity
gtk font: $font_gtk
metacity font: $font_meta
And now make a smile
"
Final result looks like the one on the following picture:

Picture. 2 Making screenshots, in a less common way
We warmly encourage you to place your own scripts in comments. Or to tell us about other applications which facilitate the use of the sophisticated configure manager.
Proof-read by trashcat and P2O2
Subscribe to RSS feed for this article!
3 Comments
- A hyperlink: <a href="polishlinux.org">GNU/Linux for everyone!</a>,
- Strong text: <strong>Strong text</strong>,
- Italic text: <em>italic text</em>,
- Strike: <strike>
strike</strike>, - Code: <code>
printf("hello world");</code>, - Block quote: <blockquote>Block quote</blockquote>


I have to say that there is gconf-cleaner released

code.google.com/p/gconf-cleaner/
the sole purpose is to clean waste entries of gconf-registry
Why do we need gconf?it sucks ? and I love Gnome too.
As mentioned, the default for most systems is to show the contents of the ~/Desktop directory as icons on the desktop. However, if you rmdir this directory, Nautilus(?) will switch to showing your whole home directory as icons on the desktop. Re-creating the directory will not revert back to the default behavior, even if the gconf key
/apps/nautilus/preferences/desktop_is_home_diris false. See Bugzilla #251301, can anyone shed more light on this?God bless gconf creators…
They had to feel really down to give the birth to such useless and obscure crap like gconf.
They said it was created to help administrators…I wonder if they asked firstly to some administrators if they would prefer plain clean text files instead of such rubbish.