Skip to content

Commit

Permalink
Merge branch 'yshui:next' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
FT-Labs authored Dec 22, 2023
2 parents 7336e41 + 496452c commit 2172846
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
12 changes: 7 additions & 5 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -596,23 +596,25 @@ char *locate_auxiliary_file(const char *scope, const char *path, const char *inc
// Fall back to searching in user config directory
scoped_charp picom_scope = mstrjoin("/picom/", scope);
scoped_charp config_home = (char *)xdg_config_home();
char *ret = locate_auxiliary_file_at(config_home, picom_scope, path);
if (ret) {
return ret;
if (config_home) {
char *ret = locate_auxiliary_file_at(config_home, picom_scope, path);
if (ret) {
return ret;
}
}

// Fall back to searching in system config directory
auto config_dirs = xdg_config_dirs();
for (int i = 0; config_dirs[i]; i++) {
ret = locate_auxiliary_file_at(config_dirs[i], picom_scope, path);
char *ret = locate_auxiliary_file_at(config_dirs[i], picom_scope, path);
if (ret) {
free(config_dirs);
return ret;
}
}
free(config_dirs);

return ret;
return NULL;
}

/**
Expand Down
14 changes: 8 additions & 6 deletions src/config_libconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,19 @@ FILE *open_config_file(const char *cpath, char **ppath) {

// First search for config file in user config directory
auto config_home = xdg_config_home();
auto ret = open_config_file_at(config_home, ppath);
free((void *)config_home);
if (ret) {
return ret;
if (config_home) {
auto ret = open_config_file_at(config_home, ppath);
free((void *)config_home);
if (ret) {
return ret;
}
}

// Fall back to legacy config file in user home directory
const char *home = getenv("HOME");
if (home && strlen(home)) {
auto path = mstrjoin(home, config_filename_legacy);
ret = fopen(path, "r");
auto ret = fopen(path, "r");
if (ret && ppath) {
*ppath = path;
} else {
Expand All @@ -105,7 +107,7 @@ FILE *open_config_file(const char *cpath, char **ppath) {
// Fall back to config file in system config directory
auto config_dirs = xdg_config_dirs();
for (int i = 0; config_dirs[i]; i++) {
ret = open_config_file_at(config_dirs[i], ppath);
auto ret = open_config_file_at(config_dirs[i], ppath);
if (ret) {
free(config_dirs);
return ret;
Expand Down

0 comments on commit 2172846

Please sign in to comment.