From 5e5b9e305062b2848c9ed28104f2cfe52e3ca075 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 20 May 2021 16:01:25 +1000 Subject: [PATCH] conf: PIPEWIRE_CONFIG_DIR should take precedence if set This matches the behavior of most applications - check environment variables first, then fall back to the various built-in options (in our case xdg, /etc/ /usr/share, in that order). --- src/pipewire/conf.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/pipewire/conf.c b/src/pipewire/conf.c index 70ebbd5d9..91b96c50c 100644 --- a/src/pipewire/conf.c +++ b/src/pipewire/conf.c @@ -77,6 +77,14 @@ static int get_read_path(char *path, size_t size, const char *prefix, const char return -ENOENT; } + dir = getenv("PIPEWIRE_CONFIG_DIR"); + if (dir != NULL) { + const char *paths[] = { dir, prefix, name, NULL }; + if (make_path(path, size, paths) == 0 && + access(path, R_OK) == 0) + return 1; + } + dir = getenv("XDG_CONFIG_HOME"); if (dir != NULL) { const char *paths[] = { dir, "pipewire", prefix, name, NULL }; @@ -96,9 +104,8 @@ static int get_read_path(char *path, size_t size, const char *prefix, const char access(path, R_OK) == 0) return 1; } - dir = getenv("PIPEWIRE_CONFIG_DIR"); - if (dir == NULL) - dir = PIPEWIRE_CONFIG_DIR; + + dir = PIPEWIRE_CONFIG_DIR; if (dir != NULL) { const char *paths[] = { dir, prefix, name, NULL }; if (make_path(path, size, paths) == 0 &&