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.
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
WordPress converted double minus signs to en dashes in your post, making the commands not copy-pasteable.
@Marius Gedminas – thank you for noticing, i have updated the post.
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
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.
@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.
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?
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.
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
Thank,
great article. If you don’t min I’ll ref it on http://blog.vnox.de/ in my next article.
Just a slight addition: As above you need to swat entry no 1 and no 3 in order to have the same order as listed in “System -> Pref -> Apprearance”, i.e. see below:
# 1. Application Font
gconftool-2 –set /desktop/gnome/interface/font_name –type string “Ubuntu 9”
# 2. Document Font
gconftool-2 –set /desktop/gnome/interface/document_font_name –type string “Sans 8”
# 3. Desktop Font
gconftool-2 –set /apps/nautilus/preferences/desktop_font –type string “Ubuntu 9”
# 4. Widows Title Font
gconftool-2 –set /apps/metacity/general/titlebar_font –type string “Ubuntu Bold 9”
# 3. Fixed Width Font
gconftool-2 –set /desktop/gnome/interface/monospace_font_name –type string “Monospace 8”
Re
@ xtraxtra
In the script you have to set the DBUS_SESSION_BUS_ADDRESS value to the value it has on the desktop.
> Using gconftool-2 we can achieve the same thing using:
> gconftool-2 –set /apps/gnome-screensaver/lock_enabled –type bool 1″
You were missing a “.
Hi!
Great post, I am trying to add US and Bhutanese keyboard layout from terminal so that I can include the command to my script. I am testing it on Linux Mint 14. I tried using this command:
gconftool-2 –set –type list –list-type string /desktop/gnome/peripherals/keyboard/kbd/layouts [bt,us]
gsettings set org.gnome.libgnomekbd.keyboard layouts “[‘bt’,’us’]”
But it doesn’t work. Please help.