|
|
@ -549,43 +549,34 @@ static bool load_include_config(const char *path, const char *parent_dir,
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool load_include_configs(const char *path, struct sway_config *config,
|
|
|
|
void load_include_configs(const char *path, struct sway_config *config,
|
|
|
|
struct swaynag_instance *swaynag) {
|
|
|
|
struct swaynag_instance *swaynag) {
|
|
|
|
char *wd = getcwd(NULL, 0);
|
|
|
|
char *wd = getcwd(NULL, 0);
|
|
|
|
char *parent_path = strdup(config->current_config_path);
|
|
|
|
char *parent_path = strdup(config->current_config_path);
|
|
|
|
const char *parent_dir = dirname(parent_path);
|
|
|
|
const char *parent_dir = dirname(parent_path);
|
|
|
|
|
|
|
|
|
|
|
|
if (chdir(parent_dir) < 0) {
|
|
|
|
if (chdir(parent_dir) < 0) {
|
|
|
|
free(parent_path);
|
|
|
|
sway_log(SWAY_ERROR, "failed to change working directory");
|
|
|
|
free(wd);
|
|
|
|
goto cleanup;
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wordexp_t p;
|
|
|
|
wordexp_t p;
|
|
|
|
|
|
|
|
if (wordexp(path, &p, 0) == 0) {
|
|
|
|
if (wordexp(path, &p, 0) != 0) {
|
|
|
|
char **w = p.we_wordv;
|
|
|
|
free(parent_path);
|
|
|
|
size_t i;
|
|
|
|
free(wd);
|
|
|
|
for (i = 0; i < p.we_wordc; ++i) {
|
|
|
|
return false;
|
|
|
|
load_include_config(w[i], parent_dir, config, swaynag);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
wordfree(&p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
char **w = p.we_wordv;
|
|
|
|
// Attempt to restore working directory before returning.
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
for (i = 0; i < p.we_wordc; ++i) {
|
|
|
|
|
|
|
|
load_include_config(w[i], parent_dir, config, swaynag);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
free(parent_path);
|
|
|
|
|
|
|
|
wordfree(&p);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// restore wd
|
|
|
|
|
|
|
|
if (chdir(wd) < 0) {
|
|
|
|
if (chdir(wd) < 0) {
|
|
|
|
free(wd);
|
|
|
|
sway_log(SWAY_ERROR, "failed to change working directory");
|
|
|
|
sway_log(SWAY_ERROR, "failed to restore working directory");
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
|
|
|
|
free(parent_path);
|
|
|
|
free(wd);
|
|
|
|
free(wd);
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void run_deferred_commands(void) {
|
|
|
|
void run_deferred_commands(void) {
|
|
|
|