Home > GNOME, Ubuntu > gconftool-2 : gconf-editor from the shell

gconftool-2 : gconf-editor from the shell

I was sitting here this afternoon trying to come up with something to blog about. Looking at some of the wiki work I’ve done recently I realize I’ve made a good use of the gconfool-2 for customizing the GNOME Desktop all from the shell. I thought I’d share some of the basic command structures with you.

Basically what gconftool-2 will do is allow you to set GNOME environmet tweaks (font sizes, sound mixer settings, taskbar size/location, etc) from the shell vs using the graphical tool.

gconftool-2 examples

Below is an example of using the gconftool-2 to set the default font sizes to 8, as I’ve done on the EeePC.

gconftool-2 --set /apps/nautilus/preferences/desktop_font --type string "Sans 8"
gconftool-2 --set /desktop/gnome/interface/document_font_name --type string "Sans 8"
gconftool-2 --set /desktop/gnome/interface/font_name --type string "Sans 8"
gconftool-2 --set /apps/metacity/general/titlebar_font --type string "Sans Bold 8"
gconftool-2 --set /desktop/gnome/interface/monospace_font_name --type string "Monospace 8"

The above commands are the equivalent of launching the gconf-editor (ALT-F2 : gconf-editor), navigating to the paths listed above and changing the listed values. While I am very grateful that we do have a graphical tool for editing these things, you tell me which is faster?

gconftool-2 basics

The basic structure of using the gconftool-2 is the following:

gconftool-2 --set /path/to/setting --type <type> "value"

The /path/to/setting can be found using the graphical tool (unless someone can tell me an alternate method). The type can also be found in the same place. For example, let’s say I want to change toggle the value of locking the screen when the screensaver is in use. I can open the gconf-editor GUI tool, navigate through its menu tree “apps > gnome-screensaver” and find the “lock_enabled” value. Normally, by checking or unchecking this box we’d toggle the value.

Using gconftool-2 we can achieve the same thing using:

gconftool-2 --set /apps/gnome-screensaver/lock_enabled --type bool 1"

Now I understand that at this point we aren’t technically any faster because we had to look it up in the GUI anyway, but once you’ve found it the first time you should be ahead of the game the second time. This is great for installing multiple machines, or simply if you reinstall your machine regularly and want to script your settings back into place.

As per the basic structure above we’re –setting a value, giving the path to what value we want to change, and then defining the type. In this case it is an off or on boolean value. In other cases, as with the examples above, it is a string that needs to be defined. You can find out what type of value (integer, boolean, string, etc) your item uses by double-clicking within the graphical application.

I have been able to find most values in the gconf-editor or gconftool-2. Everything from toggling the proper mixer for my volume settings to setting my taskbars to a specific size.

I hope these basic examples are enough to get some of you started.

If this article has been helpful, please consider linking to it.

Categories: GNOME, Ubuntu Tags: , ,

Related Posts

  1. Gate
    January 10th, 2008 at 17:02 | #1

    You can list all keys in the tree with:
    [code]
    gconftool-2 -R /
    [/code]

    so if you wanted to find gnome-screensaver you could do
    [code]
    gconftool-2 -R / | grep screensaver
    [/code]
    and it will list various locations that have keys/values with screensaver in them

  2. January 11th, 2008 at 03:26 | #2

    WordPress converted double minus signs to en dashes in your post, making the commands not copy-pasteable.

  3. admin
    January 11th, 2008 at 10:37 | #3

    @Marius Gedminas – thank you for noticing, i have updated the post.

  4. Ă–jvind Johansson
    January 15th, 2008 at 02:47 | #4

    I do as follows:

    gconftool-2 -R / > gr

    Now make a change in System Preferences,
    or some application preference. Then:

    gconftool-2 -R / > g
    diff -U30 gr g | less

  5. January 16th, 2008 at 09:20 | #5

    Great tutorial. I’m interested in automating the configurations from gconf to multiple computers across a network. I have not found anything that does this. So far my only though is to export the settings to a file, and then have network computers run a script every 30 minutes to import the settings.
    Any thoughts?
    Thanks for all the great info.

  6. January 17th, 2008 at 14:43 | #6

    @Marius – that ‘bug’ should be fixed site-wide. I’ve updated all of the posts to properly display that. Thank you for pointing it out.

  7. xtraxtra
    May 6th, 2008 at 00:05 | #7

    Great tutorial, but i have this problem with changing mouse settings using
    gconftool-2 –set /desktop/gnome/peripherals/mouse/left_handed –type boolean 1
    gconftool-2 –set /desktop/gnome/peripherals/mouse/tap_to_click –type boolean 0
    while running this directly from shell it works fine
    but while running this from script done changes are visible in gconf-editor but changes take no effect to the mouse behaviour.
    Is it possible to change the mouse settings from the script?

  8. J Beazley
    April 12th, 2009 at 18:25 | #8

    Gconftool-2 can also be used to backup/import different gconf settings using the "gconftool-2 –dump" and "gconftool-2 –load" commands. For example, for panel settings:

    gconftool-2 –dump /apps/panel > ~/Desktop/panel.entries
    gconftool-2 –load ~/Desktop/panel.entries

    Useful for if you switch between multiple themes and panel configurations etc.

    Also, you could easily tweak this to backup entire desktop environment style.

  9. Marcelo
    January 17th, 2010 at 09:43 | #9

    Hi, nice tutorial.
    I’ve used it to change background images automatically every minute, it looks nice!
    it just needs a file with images paths, like: “~/Images/file.paths”,
    with its contents like:
    ~/Images/image1.png
    ~/Images/image2.png
    ~/Images/image3.jpg

    ————————————————————————————-

    #!/bin/bash
    while true; do
    BG_LIST=”~/Images/images.path”
    list_size_with_name=`wc -l $BG_LIST`
    list_size=`echo $list_size_with_name | awk ‘{print $1}’`
    i=`expr $RANDOM % $list_size`
    string=`cat $BG_LIST | sed -n -e “$i{p;q}”`
    /usr/bin/gconftool-2 –type string –set /desktop/gnome/background/picture_filename “$string”
    sleep 60
    done