diff --git a/lib/wp/base-dirs.c b/lib/wp/base-dirs.c index 9ab57c62..0a41ff55 100644 --- a/lib/wp/base-dirs.c +++ b/lib/wp/base-dirs.c @@ -62,12 +62,32 @@ lookup_dirs (guint flags) dir = g_get_user_config_dir (); g_ptr_array_add (dirs, g_build_filename (dir, "wireplumber", NULL)); } - if (flags & WP_BASE_DIRS_ETC) + if (flags & WP_BASE_DIRS_XDG_DATA_HOME) { + dir = g_get_user_data_dir (); + g_ptr_array_add (dirs, g_build_filename (dir, "wireplumber", NULL)); + } + if (flags & WP_BASE_DIRS_XDG_CONFIG_DIRS) { + const gchar * const *xdg_dirs = g_get_system_config_dirs (); + for (guint i = 0; xdg_dirs[i]; i++) { + g_ptr_array_add (dirs, g_build_filename (xdg_dirs[i], "wireplumber", + NULL)); + } + } + if (flags & WP_BASE_DIRS_ETC) { g_ptr_array_add (dirs, g_canonicalize_filename (WIREPLUMBER_DEFAULT_CONFIG_DIR, NULL)); - if (flags & WP_BASE_DIRS_PREFIX_SHARE) + } + if (flags & WP_BASE_DIRS_XDG_DATA_DIRS) { + const gchar * const *xdg_dirs = g_get_system_data_dirs (); + for (guint i = 0; xdg_dirs[i]; i++) { + g_ptr_array_add (dirs, g_build_filename (xdg_dirs[i], "wireplumber", + NULL)); + } + } + if (flags & WP_BASE_DIRS_PREFIX_SHARE) { g_ptr_array_add (dirs, g_canonicalize_filename(WIREPLUMBER_DEFAULT_DATA_DIR, NULL)); + } } return g_steal_pointer (&dirs); diff --git a/lib/wp/base-dirs.h b/lib/wp/base-dirs.h index 92d9cdf9..122bce9b 100644 --- a/lib/wp/base-dirs.h +++ b/lib/wp/base-dirs.h @@ -22,9 +22,28 @@ typedef enum { /*< flags >*/ WP_BASE_DIRS_ENV_CONFIG = (1 << 0), /*!< $WIREPLUMBER_CONFIG_DIR */ WP_BASE_DIRS_ENV_DATA = (1 << 1), /*!< $WIREPLUMBER_DATA_DIR */ - WP_BASE_DIRS_XDG_CONFIG_HOME = (1 << 10), /*!< XDG_CONFIG_HOME/wireplumber */ - WP_BASE_DIRS_ETC = (1 << 11), /*!< ($prefix)/etc/wireplumber */ - WP_BASE_DIRS_PREFIX_SHARE = (1 << 12), /*!< $prefix/share/wireplumber */ + WP_BASE_DIRS_XDG_CONFIG_HOME = (1 << 8), /*!< XDG_CONFIG_HOME/wireplumber */ + WP_BASE_DIRS_XDG_DATA_HOME = (1 << 9), /*!< XDG_DATA_HOME/wireplumber */ + + WP_BASE_DIRS_XDG_CONFIG_DIRS = (1 << 10), /*!< XDG_CONFIG_DIRS/wireplumber */ + WP_BASE_DIRS_XDG_DATA_DIRS = (1 << 11), /*!< XDG_DATA_DIRS/wireplumber */ + + WP_BASE_DIRS_ETC = (1 << 16), /*!< ($prefix)/etc/wireplumber */ + WP_BASE_DIRS_PREFIX_SHARE = (1 << 17), /*!< $prefix/share/wireplumber */ + + WP_BASE_DIRS_CONFIGURATION = + WP_BASE_DIRS_ENV_CONFIG | + WP_BASE_DIRS_XDG_CONFIG_HOME | + WP_BASE_DIRS_XDG_CONFIG_DIRS | + WP_BASE_DIRS_ETC | + WP_BASE_DIRS_XDG_DATA_DIRS | + WP_BASE_DIRS_PREFIX_SHARE, + + WP_BASE_DIRS_DATA = + WP_BASE_DIRS_ENV_DATA | + WP_BASE_DIRS_XDG_DATA_HOME | + WP_BASE_DIRS_XDG_DATA_DIRS | + WP_BASE_DIRS_PREFIX_SHARE, } WpBaseDirsFlags; WP_API diff --git a/modules/module-lua-scripting/module.c b/modules/module-lua-scripting/module.c index b9a0bfd6..df64922d 100644 --- a/modules/module-lua-scripting/module.c +++ b/modules/module-lua-scripting/module.c @@ -39,12 +39,8 @@ wp_lua_scripting_package_searcher (lua_State *L) const gchar *name = luaL_checkstring (L, 1); g_autoptr (GError) error = NULL; g_autofree gchar *filename = g_strdup_printf ("%s.lua", name); - g_autofree gchar *script = wp_base_dirs_find_file ( - WP_BASE_DIRS_ENV_DATA | - WP_BASE_DIRS_XDG_CONFIG_HOME | - WP_BASE_DIRS_ETC | - WP_BASE_DIRS_PREFIX_SHARE, - "scripts/lib", filename); + g_autofree gchar *script = + wp_base_dirs_find_file (WP_BASE_DIRS_DATA, "scripts/lib", filename); if (!script) { lua_pushliteral (L, "script not found"); @@ -142,11 +138,7 @@ find_script (const gchar * script, WpCore *core) g_file_test (script, G_FILE_TEST_IS_REGULAR)) return g_strdup (script); - return wp_base_dirs_find_file (WP_BASE_DIRS_ENV_DATA | - WP_BASE_DIRS_XDG_CONFIG_HOME | - WP_BASE_DIRS_ETC | - WP_BASE_DIRS_PREFIX_SHARE, - "scripts", script); + return wp_base_dirs_find_file (WP_BASE_DIRS_DATA, "scripts", script); } static void