Archive for September, 2009

Change dynamic library search path for an executable

Monday, September 21st, 2009

Each executable contains a list of pathes for loading dynamic library. You can get this list using:
readelf -d executable_name
chrpath -l executable_name

And it is possible to change this path using:
chrpath -r new_path_separated_by_double_colon executable_name

There are more detailled explanation here:

Read a gconf value and return a default value if missing

Saturday, September 12th, 2009

A function like gconf_client_get_bool returns FALSE if the value is set to FALSE or if the value is missing. Moreover, the err argument is not set, if the value is missing.

One way to return another default value if the key is missing is to use the function gconf_client_get that will return NULL in this case.

A function to get a boolean value can be written like:

static gboolean
get_bool_default (GConfClient *client, const gchar *key, gboolean def)
    gboolean value = def;
    GConfValue* val;

    val = gconf_client_get (client, key, NULL);
    if (val != NULL)
        value = gconf_value_get_bool (val);
        gconf_value_free (val);

    return value;

I haven’t found a way to remove a not user defined gconf key, so to check this code, my current solution is just to read another key.