GNOME 2.0 Desktop for the Solaris Operating Environment System Administration Guide

Chapter 1 Using GConf

The information in this chapter describes how to use GConf to manage user preferences.

Introducing GConf

GConf simplifies the administration of preferences for users in the desktop environment. GConf enables system administrators to do the following:

GConf also notifies applications when a preference value changes, locally or across a network. In this way, when you change a preference, all applications that use the preference are immediately updated.

GConf has the following components:

GConf Repository

Each preference in the GConf repository is expressed as a key-value pair. A GConf preference key is an element in the repository that corresponds to an application preference. For example, the /apps/gnome-session/options/show_splash_screen preference key corresponds to the Show splash screen on login option in the Sessions preference tool. The GNOME Desktop user interface does not contain all of the preference keys in the GConf repository. For example, the Sessions preference tool does not contain an option that corresponds to the /apps/gnome-session/options/splash_screen_text key.

The repository is structured like a simple hierarchical file system. The repository contains the following:

Preference keys typically have simple values such as strings, integers, or lists of strings and integers. The format of the preference key in the repository depends on the backend module that is used to read the repository. The following is an example of the /desktop/gnome/interface/font_name preference key when an Extensible Markup Language (XML) backend module is used to read the repository:

<entry name="font_name" mtime="1038323555" muser="user123" type="string">
<stringvalue>avantgarde 10</stringvalue></entry>

Note –

When this guide refers to a preference key, the path to the key is added to the name of the key. For example, the font_name preference key in the /desktop/gnome/interface subdirectory is referred to as /desktop/gnome/interface/font_name.


GConf Configuration Sources

The GConf repository contains a series of storage locations that are called configuration sources. The configuration sources are listed in the GConf path file. The location of the GConf path file is /etc/gconf/version-number/path. Each user has a path file. Each line in the path file specifies the following information:

By default, the contents of the GConf path file are as follows:

xml:readonly:/etc/gconf/gconf.xml.mandatory
include "$(HOME)/.gconf.path"
xml:readwrite:$(HOME)/.gconf
xml:readonly:/etc/gconf/gconf.xml.defaults

When GConf searches for a preference value, GConf reads the configuration sources in the order specified in the path file. The following table describes the configuration sources in the path file:

Configuration Source 

Description 

Mandatory 

The permissions on this configuration source are set to read only. Users cannot overwrite the values in this source, so the preferences in the source are mandatory. 

User 

This configuration source is stored in the .gconf directory in the home directory of the user. When the user sets a preference, the new preference information is added to this location.

Default 

This configuration source contains the default preference settings. 

The sequence of the configuration sources in the path file ensures that mandatory preference settings override user preference settings. The sequence also ensures that user preference settings override default preference settings. That is, GConf applies preferences in the following order of priority:

  1. Mandatory preferences

  2. User-specified preferences

  3. Default preferences

The include instruction in the GConf path file enables users to use another configuration source. To use another configuration source, the user must specify the location of the configuration source. The user specifies the location of the configuration source in the home directory, in a file that is called .gconf.path.

GConf Schemas

A GConf schema is a collective term for a GConf schema key and a GConf schema object. The following table describes schema keys and schema objects and the relationship of these items to preference keys:

Item 

Description 

Preference key 

An element in the GConf repository that corresponds to an application preference.

Schema key 

A key that stores a schema object for a preference key.  

Schema object 

An element in a configuration source that contains information for a preference key, such as the following: 

  • The name of the application that uses the preference key.

  • The type of value required for the preference key, for example integer, boolean, and so on.

  • A default value for the preference key.

  • Brief documentation on the preference key.

The following table gives examples of a preference key, a schema key, and a schema object:

Item 

Example 

Preference key 

/desktop/gnome/interface/font_name

Schema key 

/schemas/desktop/gnome/interface/font_name

Schema object 

<schema>
  <applyto>/desktop/gnome/interface/font_name</applyto>
  <key>/schemas/desktop/gnome/interface/font_name</key>
  <owner>gnome</owner>
  <type>string</type>
  <default>Sans 10</default>
  <locale name="C">
    <short>Default font</short>
      <long>Name of the default font used by gtk+.</long>
  </locale>
</schema>

You can associate a schema key with a preference key. For example, the following /desktop/gnome/interface/font_name key includes a schema key:

<entry name="font_name" mtime="1034873859" 
schema="/schemas/desktop/gnome/interface/font_name"/>

When you associate a schema key with a preference key, the preference uses the suggested value that is specified in the schema object of the schema key. The suggested value is contained in the <default> element in the schema object. By default, all the preference keys in the default configuration source are associated with schema keys.

Typically, schemas are stored in the default configuration source.

GConf Schema Definition Files

Schemas are generated from schema definition files. A schema definition file defines the characteristics of all of the keys in a particular application. Schema definition files have a .schemas extension.

The schema definition files are included in the /etc/gconf/schemas directory. You can use the schema definition files to create a new configuration source.

Some schema definition files correspond closely to a part of the GNOME Desktop user interface. For example, system_http_proxy.schemas corresponds to the Network Proxy preference tool. Other schema definition files contain preference keys that are not present in the GNOME Desktop user interface. For example, the /apps/gnome-session/options/splash_screen_text key is not present in the user interface.

Some parts of the GNOME Desktop user interface contain preferences that represent preference keys from more than one schema definition file. For example, the Keyboard Shortcuts preference tool contains preferences that represent keys from the panel-global-config.schemas and metacity.schemas files.

GConf Daemon

The GConf daemon is called gconfd-2. The GConf daemon notifies applications when a preference value changes. For example, you might select to show only icons in toolbars in the Menus & Toolbars preference tool. When you select this option in the preference tool, the toolbars on all open applications are updated instantly. The GConf daemon can operate locally, or across a network.

An instance of the GConf daemon is started for each user. The GConf daemon does not have to deal with complex problems such as authentication and data security. When the GConf daemon starts, the daemon loads the GConf path file. The GConf daemon manages all access between applications and the configuration sources.

When an application requests the value of a preference key, the daemon searches the configuration sources as follows:

  1. Search for the value of the preference key in each configuration source, in the order specified in the path file. If the value is found, return the value.

  2. If a value is not found, search for the schema key that corresponds to the preference key in each configuration source, in the order specified in the path file.

  3. If the schema key is found, check the value of the schema key.

  4. If the value of the schema key is a schema object, return the suggested value in the <default> element of the schema object.

The GConf daemon also caches preference key values. All applications use this cache, so applications only need to access the configuration sources once.

To terminate the GConf daemon, run the following command:

# gconftool-2 --shutdown

GConf Command Line Tool

GConf includes a command line tool, gconftool-2. You can use the gconftool–2 command to perform the following tasks:

For example, use the following command to display the values of all keys in the /desktop/gnome directory and subdirectories.

# gconftool-2 --recursive-list /desktop/gnome

Table 1–1 lists some of the options that you can use with the gconftool-2 command.

Table 1–1 gconftool-2 Command Options

Option 

Function 

--all-dirs

Lists all subdirectories in a directory that you specify. 

--all-entries

Displays the values of all keys in a directory that you specify. 

--config-source=configuration-source

Use this option with the --direct option to specify a configuration source to use. If you do not specify a configuration source with this option, the command runs on all configuration sources in the path file.

--direct

Use this option with the --config-source option to access a configuration source directly. When you use this option, GConf bypasses the server. Ensure that the GConf daemon, gconfd-2, is not running before you use this option.

--get

Displays the value of a preference key that you specify. Also displays the values of the elements in the schema object for a schema key that you specify. 

--help

Displays a help message about the gconftool-2 command, and the options that you can use with the gconftool-2 command.

--long-desc=description

Use this option with the --set-schema option to specify a long description for a schema key.

--makefile-install-rule

Installs schema definition files to applications. 

--owner=owner

Use this option with the --set-schema option to specify an owner for a schema key.

--recursive-list

Displays the value of all preference keys in all subdirectories in a directory that you specify. 

--recursive-unset

Resets the values of all preference keys, in all subdirectories in a directory, from the user setting to the setting in the default configuration source. 

--set

Sets the value of a preference key, and writes the value to the user configuration source. Use the --type option with the --set option to specify the data type of the value that you want to set. For example, the following command sets the value of the /apps/gnome-terminal/profiles/Default/background_color key in the user configuration source:

# gconftool-2 --set "/apps/gnome-terminal/profiles/Default/background_color" --type string "#000000"

You can also use the --direct option and the --config-source option with the --set option to write a value to another configuration source.

--set-schema

Sets the value of an attribute in a schema key, and writes the value to the default configuration source. 

Use the following options with the --set-schema option to specify the attribute that you want to update:

  • --type

  • --short-desc

  • --long-desc

  • --owner

For example, the following command sets the short description in the schema key for the /apps/gnome-terminal/profiles/Default/background_color key:

# gconftool-2 --set-schema "/schemas/apps/gnome-terminal/profiles/Default/background_color" --short-desc "Default background color of terminal"

--short-desc=description

Use this option with the --set-schema option to specify a short description for a schema key.

--shutdown

Terminates the GConf daemon.

--type=data-type

Use this option to specify the data type when you set a value of a preference key. You can also use this option when you set the value of an attribute in a schema key. The following is a list of valid data types: 

  • bool

  • float

  • int

  • list

  • pair

  • string

--unset

Resets the value of a preference key from the user setting to the setting in the default configuration source. 

--usage

Displays a brief help message about the gconftool-2 command, and the options that you can use with the gconftool-2 command.

To Set Preference Values

You can set a mandatory value or a default value for a preference key. Before you change mandatory preference values or default preference values for users, you must ensure that the GConf daemon is not running for any user. Ensure that all users are logged out before you change preference values for users.

To set a mandatory value or a default value for a preference key, use the gconftool-2 command, as follows:

# gconftool-2 --direct --config-source configuration-source --type data-type --set preference-key value

For example, to set wwwproxy.xyz.com as the mandatory HTTP proxy host, run the following command:

# gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --type string --set /system/http_proxy/host wwwproxy.xyz.com

The user cannot override this preference value.

You can also use the gconftool-2 command to set default values. For example, to set the default number of workspaces to five, run the following command:

# gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults --type int --set /apps/metacity/general/num_workspaces 5

The user can override this preference value.


Caution – Caution –

Before you change mandatory preference values or default preference values for users, you must ensure that all users are logged out.


Setting General Preferences

The following sections describe how to assign mandatory or default values to general preferences.

To Set HTTP Proxy Preferences

To set HTTP proxy preferences, you modify the values of the preference keys in the /system/http_proxy/ location. For example, to set a mandatory value for the HTTP proxy host, run the following command:

# gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --type string --set /system/http_proxy/host proxy-name

To set a default value for the HTTP proxy host, run the following command:

# gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults --type string --set /system/http_proxy/host proxy-name

You can also set other HTTP proxy-related preferences. For information on the other HTTP proxy preferences, see the system_http_proxy.schemas schema definition file.

To Set Print Manager Preferences

To set print manager preferences, you modify the values of the preference keys in the /apps/gnome-print-manager location. For example, if you do not want users to view the print jobs of other users, set a mandatory value as follows:

# gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --type bool --set /apps/gnome-print-manager/show_all_jobs false

To set a default value for this preference, run the following command:

# gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults --type bool --set /apps/gnome-print-manager/show_all_jobs false

You can also set other print manager preferences. For information on the other print manager preferences, see the gnome-print-manager.schemas schema definition file.

To Set the Number of Workspaces

To set a mandatory number of workspaces, use the following command:

# gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --type int --set /apps/metacity/general/num_workspaces integer

To set a default number of workspaces, use the following command:

# gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults --type int --set /apps/metacity/general/num_workspaces integer

You can also set other window manager preferences. For information on the other window manager preferences, see the metacity.schemas schema definition file.

To Set Keyboard Accessibility Preferences

To set keyboard accessibility preferences, you modify the values of the preference keys in the /desktop/gnome/accessibility/keyboard location. For example, if you want to set a mandatory value so that keyboard accessibility features are enabled, run the following command:

# gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --type bool --set /desktop/gnome/accessibility/keyboard/enable true

To set a default value for this preference, run the following command:

# gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults --type bool --set desktop/gnome/accessibility/keyboard/enable false

You can also set other keyboard accessibility preferences. For information on the other keyboard accessibility preferences, see the desktop_gnome_accessibility_keyboard.schemas schema definition file.

To Set Keyboard Shortcut Preferences

To set keyboard shortcut preferences, you modify the values of preference keys in two locations. The following table shows the locations to modify, and the part of the user interface to which the locations correspond:

GConf Location 

User Interface Component 

/apps/panel/global

Keyboard Shortcuts preference tool, Desktop section

/apps/metacity/general

Keyboard Shortcuts preference tool, Window Management section

For example, you might want users to use only the Alt + F3 keyboard shortcut to open the Run Program dialog. To set this mandatory value, run the following command:

# gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --type string --set /apps/panel/global/run_key '<Alt>F3'

You might want users to use Alt + F11 to maximize windows, by default. To set this default value, run the following command:

# gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults --type string --set /apps/metacity/window_keybindings/maximize '<Alt>F11'

You can also set other keyboard shortcut preferences. For information on the other keyboard shortcut preferences, see the panel-global-config.schemas and metacity.schemas schema definition files.

To Set Global Panel Preferences

To set global preferences for panels, you modify the values of the preference keys in the /apps/panel/global location. For example, if you do not want users to ever use panel animation, set a mandatory value as follows:

# gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --type bool --set /apps/panel/global/enable_animations false

To set a default value for this preference, run the following command:

# gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults --type bool --set /apps/panel/global/enable_animations false

You can also set other global panel preferences. For information on the other global panel preferences, see the panel-global-config.schemas schema definition file.

To Set Preferences for Individual Panels and Panel Objects

The panel-per-panel-config.schemas schema definition file specifies the following details of the panels in the desktop environment:

The configuration of individual panels and of panel objects is a complex task. To configure individual panels and panel objects, you must first understand the structure of the panel-per-panel-config.schemas schema definition file. For more information on the panel-per-panel-config.schemas schema definition file, see the next section.

To set preferences for individual panels and panel objects, you must set the values of many preferences in a configuration source. The easiest way to set the values of many preferences is to use a script. For a sample script that sets preferences for a panel and objects on the panel, see Sample Script for Setting Individual Panel Preferences.

Schema Definition File for Individual Panels and Panel Objects

The schema definition file panel-per-panel-config.schemas contains sections that specify panels and panel contents for small, medium, and large screens. The section for small screens and the section for large screens are not functional at the time of publication of this guide. To learn about preference keys for panels or panel objects, read the section for medium screens only.

The medium section of the file panel-per-panel-config.schemas is structured as follows:

  1. Preference keys that specify the general structure of panels, applets, and other panel objects in the desktop environment. The following keys specify the number of panels, applets, and other panel objects that appear in the desktop environment:

    • /apps/panel/default_profiles/medium/general/panel_id_list

    • /apps/panel/default_profiles/medium/general/applet_id_list

    • /apps/panel/default_profiles/medium/general/object_id_list

    The keys also assign identifiers to each panel, applet, and panel object. For example, the following excerpt from panel-per-panel-config.schemas specifies that two panels appear in the desktop environment:

    <key>/schemas/apps/panel/default_profiles/medium/
    general/panel_id_list</key>
    .
    .
    .
    <default>[00000001,00000002]</default>

    In panel-per-panel-config.schemas, the identifier 00000001 identifies the bottom edge panel, and the identifier 00000002 identifies the Menu Panel.

  2. Preference keys that specify the properties of the panels. The panel property keys are structured as follows:

    /apps/panel/default_profiles/medium/panels/panel-number/panel-property-key
    

    For example, the key /apps/panel/default_profiles/medium/panels/00000001/screen_edge specifies the edge of the display on which the bottom edge panel resides.

    The keys that specify the properties of the bottom edge panel are listed first. The keys that specify the properties of the Menu Panel are listed at the end of the medium section in panel-per-panel-config.schemas.

  3. Preference keys that list the panel objects, the panel object properties, and the panels in which the objects reside. For example, the following excerpt from panel-per-panel-config.schemas specifies object 00000001:

    <key>/schemas/apps/panel/default_profiles/medium/
    objects/00000001/object_type</key>
    .
    .
    .
    <default>launcher-object</default>
    .
    .
    .
    <key>/schemas/apps/panel/default_profiles/medium/
    objects/00000001/launcher_location</key>
    .
    .
    .
    <default>applications:///nautilus.desktop</default>
    .
    .
    .
    <key>/schemas/apps/panel/default_profiles/medium/
    objects/00000001/panel_id</key>
    .
    .
    .
    <default>00000002</default>

    The object is a launcher that starts Nautilus file manager. The launcher resides in the Menu Panel.

  4. Preference keys that list the applets, the applet preferences, and the panels in which the applets reside. For example, the following excerpt from panel-per-panel-config.schemas specifies applet 00000001:

    <key>/schemas/apps/panel/default_profiles/medium/
    applets/00000001/object_type</key>
    .
    .
    .
    <default>bonobo-applet</default>
    .
    .
    .
    <key>/schemas/apps/panel/default_profiles/medium/
    applets/00000001/panel_id</key>
    .
    .
    .
    <default>00000001</default>
    .
    .
    .
    <key>/schemas/apps/panel/default_profiles/medium/
    applets/00000001/bonobo_iid</key>
    .
    .
    .
    <default>OAFIID:GNOME_TasklistApplet</default>

    The applet is the Window List applet. The applet resides in the bottom edge panel.

Sample Script for Setting Individual Panel Preferences

This section contains a sample script that sets the preferences for a panel that has the following major characteristics:

The sample script also sets other minor preferences. All of the preferences have default values, not mandatory values.

The sample script follows:

# Usage is: set_key <type> <key> <value> <extra options if any>

function set_key() 
{
  TYPE="$1"
  shift
  KEY="$1"
  shift
  VALUE="$1"
  shift
  OTHER_ARGS="$*"
  gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults 
--owner=panel $OTHER_ARGS --type "$TYPE" --set "$KEY" "$VALUE"
}

# Define the number of panels, the number of launchers, and the number of applets 
set_key list /apps/panel/default_profiles/medium/general
/panel_id_list [00000001] --list-type string
set_key list /apps/panel/default_profiles/medium/general
/object_id_list [00000001,00000002] --list-type string
set_key list /apps/panel/default_profiles/medium/general
/applet_id_list [00000001] --list-type string

# Define the characteristics of the panel 
set_key string /apps/panel/default_profiles/medium/panels
/00000001/panel_type edge-panel
set_key string /apps/panel/default_profiles/medium/panels
/00000001/panel_size panel-size-x-small
set_key string /apps/panel/default_profiles/medium/panels
/00000001/screen_edge panel-edge-bottom
set_key bool /apps/panel/default_profiles/medium/panels
/00000001/hide_buttons_enabled false
set_key string /apps/panel/default_profiles/medium/panels
/00000001/panel_background_type no-background

# Define the first launcher
set_key string /apps/panel/default_profiles/medium/objects
/00000001/object_type launcher-object
set_key string /apps/panel/default_profiles/medium/objects
/00000001/launcher_location 'applications:///nautilus.desktop'
set_key string /apps/panel/default_profiles/medium/objects
/00000001/panel_id 00000001
set_key int /apps/panel/default_profiles/medium/objects
/00000001/position 20

# Define the second launcher
set_key string /apps/panel/default_profiles/medium/objects
/00000002/object_type launcher-object
set_key string /apps/panel/default_profiles/medium/objects
/00000002/launcher_location 'applications:///System/gnome-terminal.desktop'
set_key string /apps/panel/default_profiles/medium/objects
/00000002/panel_id 00000001
set_key int /apps/panel/default_profiles/medium/objects
/00000002/position 25

# Define the applet
set_key string /apps/panel/default_profiles/medium/applets
/00000001/object_type bonobo-applet
set_key string /apps/panel/default_profiles/medium/applets
/00000001/bonobo_iid OAFIID:GNOME_TasklistApplet
set_key string /apps/panel/default_profiles/medium/applets
/00000001/panel_id 00000001
set_key int /apps/panel/default_profiles/medium/applets
/00000001/position 25

Setting Look-and-Feel Preferences

The following sections describe how to assign mandatory or default values to look-and-feel preferences.

To Set Font Preferences

To set font preferences, you modify the values of two preference keys. The following table shows the keys to modify, and the part of the user interface to which the keys correspond:

GConf Location 

User Interface Component 

/desktop/gnome/interface/font_name 

Font preference tool, Application font section

/apps/nautilus/preferences/desktop_font 

Font preference tool, Desktop font section

For example, to set Sans 12 as the mandatory application font, run the following command:

# gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --type string --set /desktop/gnome/interface/font_name “Sans 12”

To set palatino 12 as the default desktop object font, run the following command:

# gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults --type string --set /apps/nautilus/preferences/desktop_font “palatino 12”

To Set Desktop Background Preferences

To set desktop background preferences, you modify the values of the preference keys in the /desktop/gnome/background location. For example, to set a mandatory image for the desktop background, run the following command:

# gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --type string --set /desktop/gnome/background/picture_filename filename.png

To set a default value for this preference, run the following command:

# gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults --type string --set /desktop/gnome/background/picture_filename filename.png

You can also set other desktop background preferences. For information on the other desktop background preferences, see the desktop_gnome_background.schemas schema definition file.

To Set Splash Image Preferences

To set splash image preferences, you modify the value of the preference keys in the /apps/gnome-session/options/ location. For example, if you do not want users ever to see a splash image, set a mandatory value as follows:

# gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --type bool --set /apps/gnome-session/options/show_splash_screen false

To set a default value for this preference, run the following command:

# gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults --type bool --set /apps/gnome-session/options/show_splash_screen false

You can also set other splash image preferences. For information on the other splash image preferences, see the gnome-session.schemas schema definition file.

To Restore Default Preference Values

To restore the default preference values for a user, run the following command:

# gconftool-2 --direct --config-source user-configuration-source --recursive-unset

Replace user-configuration-source with the configuration source in the .gconf directory in the home directory of the user.

This command resets the values of all preference keys, in all subdirectories, from the user setting to the setting in the default configuration source.