Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

9.5. Configuring Custom Default Values

Machine-wide default settings can be set by providing a default for a key in a dconf profile. These defaults can be overridden by the user.
To set a default for a key, the user profile must exist and the value for the key must be added to a dconf database.

Example 9.1. Set the Default Background

  1. If it does not already exist, create the user profile in /etc/dconf/profile/user:
    user-db:user
    system-db:local
    where local is the name of a dconf database.
  2. Create a keyfile for the local database in /etc/dconf/db/local.d/01-background, which contains the following default settings:
    # dconf path
    [org/gnome/desktop/background]
    
    # GSettings key names and their corresponding values
    picture-uri='file:///usr/local/share/backgrounds/wallpaper.jpg'
    picture-options='scaled'
    primary-color='000000'
    secondary-color='FFFFFF'
    In the default setting of the keyfile, the following GSettings keys are used:

    Table 9.1. org.gnome.desktop.background schemas GSettings Keys

    Key NamePossible ValuesDescription
    picture-options"none", "wallpaper", "centered", "scaled", "stretched", "zoom", "spanned"Determines how the image set by wallpaper_filename is rendered.
    picture-urifilename with the pathURI to use for the background image. Note that the backend only supports local (file://) URIs.
    primary-colordefault: 000000Left or Top color when drawing gradients, or the solid color.
    secondary-colordefault: FFFFFFRight or Bottom color when drawing gradients, not used for solid color.
  3. Edit the keyfile according to your preferences. For more information, see Section 9.3, “Browsing GSettings Values for Desktop Applications”.
  4. Update the system databases:
    # dconf update

Important

When the user profile is created or changed, the user will need to log out and log in again before the changes will be applied.
If you want to avoid creating a user profile, you can use the dconf command-line utility to read and write individual values or entire directories from and to a dconf database. For more information, see the dconf(1) man page.

9.5.1. Locking Down Specific Settings

The lockdown mode in dconf is a useful tool for preventing users from changing specific settings.
To lock down a GSettings key, you will need to create a locks subdirectory in the keyfile directory (for instance, /etc/dconf/db/local.d/locks/). The files inside this directory contain a list of keys to lock, and you may add any number of files to this directory.

Important

If you do not enforce the system settings using a lockdown, users can easily override the system settings with their own. Any settings users have made will take precedence over the system settings unless there is a lockdown enforcing the system settings.
The example below demonstrates how to lock settings for the default wallpaper. Follow the procedure for any other setting you need to lock.

Example 9.2. Locking Down the Default Wallpaper

  1. Set a default wallpaper by following steps in Section 10.5.1, “Customizing the Default Desktop Background”.
  2. Create a new directory named /etc/dconf/db/local.d/locks/.
  3. Create a new file in /etc/dconf/db/local.d/locks/00-default-wallpaper with the following contents, listing one key per line:
    # Prevent users from changing values for the following keys:
    /org/gnome/desktop/background/picture-uri
    /org/gnome/desktop/background/picture-options
    /org/gnome/desktop/background/primary-color
    /org/gnome/desktop/background/secondary-color
  4. Update the system databases:
    # dconf update