10.5. Customizing Desktop Backgrounds
Using the
dconf
utility, you can configure the default background, add extra backgrounds, or add multiple backgrounds.
If the users of the system will not be permitted to change these settings from the defaults, then system administrators need to lock the settings using the locks directory. Otherwise each user will be able to customize the setting to suit their own preferences. For more information, see Section 9.5.1, “Locking Down Specific Settings”.
10.5.1. Customizing the Default Desktop Background
You can configure the default desktop background and its appearance by setting the relevant GSettings keys in the
org.gnome.desktop.background
schema.
For more information about GSettings, see Chapter 9, Configuring Desktop with GSettings and dconf.
Procedure 10.10. Setting the Default Background
- Create a
local
database for machine-wide settings in/etc/dconf/db/local.d/00-background
:# Specify the dconf path [org/gnome/desktop/background] # Specify the path to the desktop background image file picture-uri='file:///usr/local/share/backgrounds/wallpaper.jpg' # Specify one of the rendering options for the background image: # 'none', 'wallpaper', 'centered', 'scaled', 'stretched', 'zoom', 'spanned' picture-options='scaled' # Specify the left or top color when drawing gradients or the solid color primary-color='000000' # Specify the right or bottom color when drawing gradients secondary-color='FFFFFF'
- Override the user's setting to prevent the user from changing it in
/etc/dconf/db/local.d/locks/background
:# List the keys used to configure the desktop background /org/gnome/desktop/background/picture-uri /org/gnome/desktop/background/picture-options /org/gnome/desktop/background/primary-color /org/gnome/desktop/background/secondary-color
For more information, see Section 9.5.1, “Locking Down Specific Settings”. - Update the system databases:
#
dconf update
- Users must log out and back in again before the system-wide settings take effect.
10.5.2. Adding Extra Backgrounds
You can make extra backgrounds available to users on your system.
- Create a filename.xml file (there are no requirements for file names) specifying your extra background's appearance using the org.gnome.desktop.background schemas. Here is a list of the most frequently used schemas:
Table 10.1. org.gnome.desktop.background schemas GSettings Keys Key Name Possible Values Description picture-options "none", "wallpaper", "centered", "scaled", "stretched", "zoom", "spanned" Determines how the image set by wallpaper_filename is rendered. color-shading-type "horizontal", "vertical", and "solid" How to shade the background color. primary-color default: #023c88 Left or Top color when drawing gradients, or the solid color. secondary-color default: #5789ca Right or Bottom color when drawing gradients, not used for solid color. The full range of options is to be found in thedconf-editor
GUI orgsettings
command-line utility. For more information, see Section 9.3, “Browsing GSettings Values for Desktop Applications”. - Store the filename.xml file in the
/usr/share/gnome-background-properties/
directory.
When the user clicks their name in the top right corner, chooses Personal section of the table selects Background, they will see the new background available.
, and in the
Look at the example and see how org.gnome.desktop.background GSettings keys are implemented practically:
Example 10.4. Extra Backgrounds File
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE wallpapers SYSTEM "gnome-wp-list.dtd"> <wallpapers> <wallpaper deleted="false"> <name>Company Background</name> <name xml:lang="de">Firmenhintergrund</name> <filename>/usr/local/share/backgrounds/company-wallpaper.jpg</filename> <options>zoom</options> <shade_type>solid</shade_type> <pcolor>#ffffff</pcolor> <scolor>#000000</scolor> </wallpaper> </wallpapers>
In one configuration file, you can specify multiple
<wallpaper>
elements to add more backgrounds.
See the following example which shows an .xml file with two
<wallpaper>
elements, adding two different backgrounds:
Example 10.5. Extra Backgrounds File with Two Wallpaper Elements
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE wallpapers SYSTEM "gnome-wp-list.dtd"> <wallpapers> <wallpaper deleted="false"> <name>Company Background</name> <name xml:lang="de">Firmenhintergrund</name> <filename>/usr/local/share/backgrounds/company-wallpaper.jpg</filename> <options>zoom</options> <shade_type>solid</shade_type> <pcolor>#ffffff</pcolor> <scolor>#000000</scolor> </wallpaper> <wallpaper deleted="false"> <name>Company Background 2</name> <name xml:lang="de">Firmenhintergrund 2</name> <filename>/usr/local/share/backgrounds/company-wallpaper-2.jpg</filename> <options>zoom</options> <shade_type>solid</shade_type> <pcolor>#ff0000</pcolor> <scolor>#00ffff</scolor> </wallpaper> </wallpapers>
10.5.3. Setting the Screen Shield
Screen Shield is the screen that quickly slides down when the system is locked. It is controlled by the
org.gnome.desktop.screensaver.picture-uri
GSettings key. Since GDM
uses its own dconf
profile, you can set the default background by changing the settings in that profile.
For more information about GSettings and
dconf
, see Chapter 9, Configuring Desktop with GSettings and dconf.
Procedure 10.11. Adding a Logo to the Screen Shield
- Create a
gdm
database for machine-wide settings in/etc/dconf/db/gdm.d/01-screensaver
:[org/gnome/desktop/screensaver] picture-uri='file:///opt/corp/background.jpg'
Replace /opt/corp/background.jpg with the path to the image file you want to use as the Screen Shield.Supported formats are PNG, JPG, JPEG, and TGA. The image will be scaled if necessary to fit the screen. - Update the system databases:
#
dconf update
- You must log out before the system-wide settings take effect.
Next time you lock the screen, the new Screen Shield will show in the background. In the foreground, time, date and the current day of the week will be displayed.
10.5.3.1. What If the Screen Shield Does Not Update?
Make sure that you have run the
dconf update
command as root to update the system databases.
In case the background does not update, try restarting
GDM
. For more information, see Section 14.1.1, “Restarting GDM”.