using-gconftool-2-to-tweak-settings
LOGS
01:00:36 <ardchoille> #startmeeting Using gconftool-2 to tweak settings
01:00:36 <zodbot> Meeting started Tue Jun 15 01:00:36 2010 UTC.  The chair is ardchoille. Information about MeetBot at http://wiki.debian.org/MeetBot.
01:00:36 <zodbot> Useful Commands: #action #agreed #halp #info #idea #link #topic.
01:00:50 <ardchoille> #meetingname using-gconftool-2-to-tweak-settings
01:00:50 <zodbot> The meeting name has been set to 'using-gconftool-2-to-tweak-settings'
01:00:58 <ardchoille> #topic Introduction/Welcome
01:01:07 <ardchoille> Welcome everyone to another fedora irc class.
01:01:16 <ardchoille> As always, feel free to ask questions as the class goes on. I will have a walkthrough and Q&A session at the end of the class.
01:01:35 <ardchoille> This class will be describing how to use the gconftool-2 app to tweak various settings in the gnome desktop environment and we'll have an example toward the end.
01:02:05 <ardchoille> #topic What is gconf?
01:02:13 <ardchoille> #link http://projects.gnome.org/gconf/
01:02:26 <ardchoille> In order to understand what gconftool-2 is, and what it does, it's necessary to know something about gconf.
01:02:55 <ardchoille> GConf is a system for storing application preferences. It is intended for user preferences; not configuration of something like Apache, or arbitrary data storage.
01:03:33 <ardchoille> The root motivation for GConf is to make application preferences more manageable for users and system administrators.
01:04:06 <ardchoille> Another important motivation for GConf is that it's "process transparent."
01:04:23 <ardchoille> This means that if I change a setting from one application, it instantly updates in all other applications that are interested in that setting.
01:04:55 <ardchoille> This technology is vital for the "instant apply" UI of GNOME 2, and vital for writing applications made up of multiple out-of-process components.
01:05:03 <NiveusLuna> Will any of this apply to non-gnome DEs, such as XFCE? It uses a lot of gnome components.
01:05:26 <ardchoille> AFAIK, this only applies to the gnome DE
01:06:35 <ardchoille> NiveusLuna: If XFCE uses Gcong, then I assume this appies to that DE as well.
01:06:40 <ardchoille> *Gconf
01:06:47 <ardchoille> One of the things many users like about gnome is that, when changing a setting, there's not usually the need for an "Apply" button because most settings are "applied" from the moment the setting is changed.
01:07:22 <ardchoille> Essentially GConf provides a preferences database, which is like a simple filesystem.
01:07:53 <ardchoille> The filesystem contains keys organized into a hierarchy. Each key is either a directory containing more keys, or has a value.
01:08:34 <ardchoille> For example, the key /apps/metacity/general/titlebar_font contains an integer value giving the size of the titlebar font for the Metacity window manager.
01:09:09 <ardchoille> GConf comes with a command line tool, called gconftool-2, that you can use to get an idea what's going on. We'll talk more about gconftool-2 in a bit.
01:09:47 <ardchoille> #topic Configuration Sources
01:10:02 <ardchoille> GConf looks for each value in a series of storage locations called configuration sources.
01:10:19 <ardchoille> These are specified in a file called /etc/gconf/<version>/path.
01:10:51 <ardchoille> Each configuration source has a backend that knows how to read it - for now, this is always the "xml" backend, which stores data in XML files.
01:11:40 <ardchoille> By default, GConf comes configured as follows:
01:11:50 <ardchoille> xml:readonly:/etc/gconf/gconf.xml.mandatory
01:12:01 <ardchoille> include "$(HOME)/.gconf.path"
01:12:14 <ardchoille> xml:readwrite:$(HOME)/.gconf
01:12:25 <ardchoille> xml:readonly:/etc/gconf/gconf.xml.defaults
01:12:46 <ardchoille> If a value is set in the first source, which is read only, then users can't delete that value, and thus can't set a value of their own. These settings become mandatory for all users.
01:13:35 <ardchoille> The "include" line allows users to insert their own configuration sources into the search path by creating a file in their home directory called .gconf.path.
01:14:13 <ardchoille> The "readwrite" source ~/.gconf is where user settings are normally written.
01:14:36 <ardchoille> The last source is where schemas are usually stored.
01:15:01 <ardchoille> A different default schema source can be specified by creating the file /etc/gconf/schema-install-source; this file changes the return value of gconftool-2 --get-default-source.
01:15:49 <ardchoille> #topic Schemas
01:16:01 <ardchoille> Keys normally have simple values such as integers, strings, or lists of those. However, a special kind of value called a schema can also be stored in GConf.
01:16:40 <ardchoille> A schema is a bundle of meta-information describing a configuration setting. This meta-information includes the type of value, short documentation on the setting, and the factory default for that value.
01:17:18 <ardchoille> Schemas are conventionally stored in the database under the /schemas top-level directory.
01:17:56 <ardchoille> Let's have an example. Open a terminal and type the following command:
01:18:05 <ardchoille> gconftool-2 --get /schemas/apps/metacity/general/num_workspaces
01:18:43 <ardchoille> If the "Type:" field is "list", then the "List Type:" field will be "integer" or the like indicating that the list is a list of integers.
01:19:19 <ardchoille> Similarly, if the "Type:" field is "pair", then types of the first and second members of the pair are given as "Car Type:" and "Cdr Type:" (the names are an odd Lisp inheritance).
01:19:46 <ardchoille> Note the "Default Value:" and documentation fields.
01:20:19 <ardchoille> Keys can have a schema name associated with them. When a key's value has not been set by the user, GConf will fall back to the factory default in the key's schema.
01:21:22 <ardchoille> Any questions so far?
01:22:30 * nirik notes that Xfce uses xfconf. It's similar, but not the same as gconf.
01:22:44 <ardchoille> Ah, good to know. thank you
01:23:03 <ardchoille> Ok, moving on..
01:23:12 <ardchoille> #topic GConf per-user daemon
01:23:22 <ardchoille> The current GConf implementation involves a per-user daemon. This daemon's primary purpose is to notify applications when a configuration value has changed.
01:24:00 <ardchoille> This explains the "instant apply" :)
01:24:23 <ardchoille> As a secondary task, it caches values, so each application doesn't have to parse XML files.
01:24:52 <ardchoille> The daemon normally exits a couple of minutes after the last application using it has exited.
01:25:15 <ardchoille> Since the daemon caches values it may not notice when new schemas are installed from "make install" or an RPM/deb package.
01:25:56 <ardchoille> #topic What is gconf-editor?
01:26:28 <ardchoille> GNOME has a program called gconf-editor which is sort of the GUI equivalent of gconftool. Gconf-editor can be considered the graphical equivalent of gconftool-2 and is used to maintain the GNOME registry.
01:27:14 <ardchoille> Gconf-editor gives users the ability to access settings stored in the XML-based GConf configuration database or registry.
01:27:54 <ardchoille> It is used primarily by developers to debug applications, or by power users to edit hidden and complex settings.
01:28:27 <ardchoille> #topic What is gconftool-2?
01:28:39 <ardchoille> Each preference in the GConf repository is expressed as a key-value pair. The default key-value pairs are installed on the system, and are known as schemas.
01:29:36 <ardchoille> gconftool-2 is the command-line interface tool that enables you to set the values of keys, display the values of keys, and install schemas from schema definition files when you install an application.
01:30:24 <ardchoille> The GConf preference keys are stored and managed by the GConf daemon (gconfd-2). These keys are cached in memory, and saved to disk in XML format when appropriate.
01:30:54 <ardchoille> #topic Finding a setting
01:31:02 <ardchoille> -a, --all-entries = Print all key/value pairs in a directory.
01:31:12 <ardchoille> --all-dirs = Print all subdirectories in a directory.
01:31:23 <ardchoille> -R, --recursive-list = Print all subdirectories and entries under a dir, recursively.
01:31:38 <ardchoille> Suppose I want to find the setting that deals with whether volumes are visible on the desktop. Nautilus manages the desktop so I know I need to tweak a setting for nautilus.
01:32:07 <ardchoille> But, which setting? How do I find a setting if, for example, I'm not using xorg and therefore don't have access to the gconf GUI tool (gconf-editor)?
01:32:50 <ardchoille> I could use a command to list all branches and settings:
01:32:57 <ardchoille> gconftool-2 -R /apps/nautilus/desktop
01:33:28 <ardchoille> While this returns a wealth of information, there's an easier way - I can use a command to recursively list only branches:
01:33:38 <ardchoille> gconftool-2 --all-dirs /apps/nautilus
01:33:56 <ardchoille> Here I find the /apps/nautilus/desktop branch, so I'm getting closer.
01:34:26 <ardchoille> Now I can use this information to list settings in that branch:
01:34:35 <ardchoille> gconftool-2 --all-entries /apps/nautilus/desktop
01:35:03 <ardchoille> which gives me a list of settings including volumes_visible.
01:35:50 <ardchoille> #topic Getting a specific setting
01:35:57 <ardchoille> -g, --get = Print the value of a key to standard output.
01:36:16 <ardchoille> The basic "get" structure of a key using gconftool-2 is as follows:
01:36:23 <ardchoille> gconftool-2 -g /path/to/setting
01:36:47 <ardchoille> This command allows you to view the current setting of a specific key.
01:37:24 <ardchoille> Let’s say I want to find the value of the 'highlighting the current line' option in gedit.
01:37:56 <ardchoille> Using the information in the previous topic, I could use this command and page through the heirarchy:
01:38:04 <ardchoille> gconftool-2 -R /apps/gedit-2 | more
01:38:29 <ardchoille> or I could search directory by directory:
01:38:35 <ardchoille> gconftool-2 --all-dirs /apps/gedit-2
01:38:49 <ardchoille> gconftool-2 --all-dirs /apps/gedit-2/preferences
01:38:59 <ardchoille> gconftool-2 --all-dirs /apps/gedit-2/preferences/editor
01:39:10 <ardchoille> gconftool-2 --all-dirs /apps/gedit-2/preferences/editor/current_line
01:39:24 <ardchoille> This last command returns nothing so I must be in the last directory in that branch. So, my next task would be to check for settings in that directory:
01:39:44 <ardchoille> gconftool-2 -a /apps/gedit-2/preferences/editor/current_line
01:39:54 <ardchoille> which returns: highlight_current_line = true
01:40:23 <ardchoille> I could have used the following command had I known the exact path:
01:40:37 <ardchoille> gconftool-2 -g /apps/gedit-2/preferences/editor/current_line/highlight_current_line
01:41:33 <ardchoille> #topic Setting a specific setting
01:41:38 <ardchoille> -s, --set = Set a key to a value and sync. Use with --type.
01:42:13 <ardchoille> Once you have found the key that needs to be edited, you can quickly set the key with a desired value.
01:42:34 <ardchoille> The basic "set" structure of a key using the gconftool-2 is as follows:
01:42:47 <ardchoille> gconftool-2 -s /path/to/setting -t <type> "value"
01:43:07 <ardchoille> Let’s say I want to edit the value of the 'highlighting the current line' option in gedit.
01:43:27 <ardchoille> I can open the gconf-editor GUI tool, navigate through its menu tree "/apps/gedit-2/preferences/editor/current_line" and find the "highlight_current_line" key.
01:43:50 <ardchoille> Normally, by checking or unchecking this box I’d toggle the value.
01:44:17 <ardchoille> I can achieve the same thing using gconftool-2 as follows:
01:44:30 <ardchoille> gconftool-2 -s /apps/gedit-2/preferences/editor/current_line/highlight_current_line -t bool "1"
01:45:57 <ardchoille> #topic Unsetting a specific setting
01:46:48 <ardchoille> Those of you who are following these commands and their output in a terminal, I advise caution with the unset commands I will post as they will actually unset the specified keys.
01:47:18 <ardchoille> -u, --unset = Unset the keys on the command line.
01:47:41 <ardchoille> Unsetting a key has the effect of removing any user-specified setting and return to the default setting. This can be useful if the user wishes to remove a setting or debug an option. An example of this would be:
01:48:02 <ardchoille> gconftool-2 -u /apps/gedit-2/preferences/editor/current_line/highlight_current_line
01:48:18 <ardchoille> This command would remove any user specified setting and return current line highlights to the default setting used when the system was installed.
01:48:37 <ardchoille> #topic Unsetting recursively
01:49:19 <ardchoille> Same caution here as in the last section. the example command I chose here unsets an entire branch of keys.. luckily that branch only holds one key on my system.
01:49:32 <ardchoille> --recursive-unset = Recursively unset all keys at or below the key/directory names on the command line.
01:49:44 <ardchoille> Recursive unsetting has the effect of removing any user-specified settings for a branch of keys and return to the default settings for that branch. This can be useful if the user wishes to remove settings for an entire branch or for debugging options.
01:50:07 <ardchoille> An example of this would be:
01:50:13 <ardchoille> gconftool-2 --recursive-unset /apps/gedit-2/preferences/editor/current_line
01:50:30 <ardchoille> This command would remove any user specified setting and return all settings within the /apps/gedit-2/preferences/editor/current_line branch to the default settings used when the system was installed.
01:50:41 <ardchoille> This particular branch contains only the highlight_current_line setting.
01:52:03 <ardchoille> Any general questions so far?
01:53:10 <ardchoille> Ok, let's move on to my favorite topic..
01:53:18 <ardchoille> #topic Automation
01:53:29 <ardchoille> I have 11 computers in my home and installing Fedora on all of them is as easy as imaging one computer and installing that image on the others.
01:54:01 <ardchoille> However, if I make a number of tweaks to the settings on one computer after imaging all of them, I would need to make the same tweaks to all computers for consistency.
01:54:34 <ardchoille> This can be done by writing a bash script which uses gconftool-2 to mirror the settings on all computers.
01:54:53 <ardchoille> An example of this type of script can be found here:
01:54:57 <ardchoille> #link http://ardchoille42.fedorapeople.org/Classroom/userprefs.html
01:56:13 <ardchoille> This particular example script only makes 6 changes. I've seen scripts like this that makes over 100 changes, so the script is only limited by the needs of the user writing the script.
01:57:12 <ardchoille> You can use the GUI tool "gconf-editor" for faster browsing of keys for settings to create your own settings script.
01:57:39 <ardchoille> As you can see, gconftool-2 makes this type of script extremely useful due to the fact that you only need to run one script to change a multitude of settings and the same script can be run on multiple machines to mirror settings.
01:58:06 <ardchoille> This type of script is the main reason that setting up a new install requires me to be in front of my computer for only a few seconds after a fresh install.
01:58:29 <ardchoille> #topic Example of get and set
01:58:44 <ardchoille> Let's see instant the effect of changing a key. Open gedit, you'll need to have both gedit and your terminal visible on the desktop for this example.
01:59:09 <ardchoille> In gedit, type some text so that you have more than one carriage return.
01:59:30 <ardchoille> Now go to your terminal emulator and run the following command:
01:59:44 <ardchoille> gconftool-2 -g /apps/gedit-2/preferences/editor/line_numbers/display_line_numbers
01:59:54 <ardchoille> Notice what was returned
02:00:06 <ardchoille> Now run the following command, replacing the word bool at the end with the opposite of what the above command returned (true/false) and watch what happens in gedit:
02:00:29 <ardchoille> gconftool-2 -s /apps/gedit-2/preferences/editor/line_numbers/display_line_numbers -t bool "bool"
02:00:56 <ardchoille> Did something in gedit change?
02:01:22 <ardchoille> You'll notice that the line number state in gedit was instantly toggled. You would also see the state of this key instantly toggled in gconf-editor if you had that app open and were watching that key.
02:01:51 <ardchoille> You can set the key back to its previous setting by running the same command and reverting the bool value.
02:02:12 <ardchoille> #topic Related reading
02:02:16 <ardchoille> More information can be found at the following sources:
02:02:22 <ardchoille> man gconftool-2
02:02:30 <ardchoille> man gconfd
02:02:42 <ardchoille> http://projects.gnome.org/gconf/  (outdated but still useful)
02:03:06 <ardchoille> #topic Q&A
02:03:09 <ardchoille> Ok, any general questions on using gconftool-2?
02:03:43 <ardchoille> I will note that some of the values I have shown are in double quotes.
02:04:12 <ardchoille> This is needed for some values and not needed for others. I believe it is safe to always double-quote the values.
02:05:08 * nirik has no questions. good info...
02:05:49 <ardchoille> When I first got into learning about gconf, I thought is was one huge mistake. However, once I began learning how it worked, I began to feel that gconf was a very good idea.
02:06:18 <ardchoille> Ok, if there are no questions, I'll end the class in a minute.
02:06:34 <nirik> thanks for teaching ardchoille!
02:06:43 <ardchoille> My pleasure :)
02:07:23 <ardchoille> Thank y ou all for coming to my class :)
02:07:28 <ardchoille> #endmeeting