support multiple directories in GSETTINGS_SCHEMA_DIR
gnome-shell extensions often ship their own gsettings schemas in a custom directory, e.g. ~/.local/share/gnome-shell/extensions/foo/schemas/
. GSettings
will not automatically pick those up because they live in non-standard directories, which the extensions solve by explicitly registering those schemas.
however, the gsettings
command line tool will not know about these extra schemas and hence is not be able to use them, e.g. gsettings list-recursively
will not contain gnome-shell extension settings installed in the user's homedir.
as a work-around, the GSETTINGS_SCHEMA_DIR
env var can be set to a directory containing an extra compiled schemas.
however, GSETTINGS_SCHEMA_DIR
only allows a single directory, effectively making it impossible to use the gsettings
tool to get/set/list settings from more than one gnome-shell extension at the time.
idea: treat GSETTINGS_SCHEMA_DIR
as a list-like env var, just like PATH
and many other env vars.
not sure if i missed something, or if i am misunderstanding something, so not opening a merge request, but this patch seems to do the trick:
diff --git a/gio/gsettingsschema.c b/gio/gsettingsschema.c
index 3a60b8c64..01fb64b5b 100644
--- a/gio/gsettingsschema.c
+++ b/gio/gsettingsschema.c
@@ -345,6 +345,7 @@ initialise_schema_sources (void)
{
const gchar * const *dirs;
const gchar *path;
+ gchar **extra_schema_dirs;
gint i;
/* iterate in reverse: count up, then count down */
@@ -357,7 +358,15 @@ initialise_schema_sources (void)
try_prepend_data_dir (g_get_user_data_dir ());
if ((path = g_getenv ("GSETTINGS_SCHEMA_DIR")) != NULL)
- try_prepend_dir (path);
+ {
+ extra_schema_dirs = g_strsplit (path, G_SEARCHPATH_SEPARATOR_S, 0);
+ for (i = 0; extra_schema_dirs[i]; i++);
+
+ while (i--)
+ try_prepend_dir (extra_schema_dirs[i]);
+
+ g_strfreev (extra_schema_dirs);
+ }
g_once_init_leave (&initialised, TRUE);
}