|
|
@ -25,9 +25,16 @@ bool load_config() {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
free(temp);
|
|
|
|
free(temp);
|
|
|
|
config = read_config(f, false);
|
|
|
|
|
|
|
|
|
|
|
|
bool config_load_success;
|
|
|
|
|
|
|
|
if (config) {
|
|
|
|
|
|
|
|
config_load_success = read_config(f, true);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
config_load_success = read_config(f, false);
|
|
|
|
|
|
|
|
}
|
|
|
|
fclose(f);
|
|
|
|
fclose(f);
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
|
|
return config_load_success;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void config_defaults(struct sway_config *config) {
|
|
|
|
void config_defaults(struct sway_config *config) {
|
|
|
@ -42,14 +49,17 @@ void config_defaults(struct sway_config *config) {
|
|
|
|
config->focus_follows_mouse = true;
|
|
|
|
config->focus_follows_mouse = true;
|
|
|
|
config->mouse_warping = true;
|
|
|
|
config->mouse_warping = true;
|
|
|
|
config->reloading = false;
|
|
|
|
config->reloading = false;
|
|
|
|
|
|
|
|
config->active = false;
|
|
|
|
|
|
|
|
config->failed = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct sway_config *read_config(FILE *file, bool is_active) {
|
|
|
|
bool read_config(FILE *file, bool is_active) {
|
|
|
|
struct sway_config *config = malloc(sizeof(struct sway_config));
|
|
|
|
struct sway_config *temp_config = malloc(sizeof(struct sway_config));
|
|
|
|
config_defaults(config);
|
|
|
|
config_defaults(temp_config);
|
|
|
|
|
|
|
|
|
|
|
|
if (is_active) {
|
|
|
|
if (is_active) {
|
|
|
|
config->reloading = true;
|
|
|
|
sway_log(L_DEBUG, "Performing configuration file reload");
|
|
|
|
|
|
|
|
temp_config->reloading = true;
|
|
|
|
|
|
|
|
temp_config->active = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool success = true;
|
|
|
|
bool success = true;
|
|
|
@ -72,14 +82,19 @@ struct sway_config *read_config(FILE *file, bool is_active) {
|
|
|
|
// Any command which would require wlc to be initialized
|
|
|
|
// Any command which would require wlc to be initialized
|
|
|
|
// should be queued for later execution
|
|
|
|
// should be queued for later execution
|
|
|
|
list_t *args = split_string(line, " ");
|
|
|
|
list_t *args = split_string(line, " ");
|
|
|
|
if (strcmp("workspace", args->items[0]) == 0) {
|
|
|
|
if (!is_active && (
|
|
|
|
|
|
|
|
strcmp("workspace", args->items[0]) == 0 ||
|
|
|
|
|
|
|
|
strcmp("exec", args->items[0]) == 0 ||
|
|
|
|
|
|
|
|
strcmp("exec_always", args->items[0]) == 0 )) {
|
|
|
|
sway_log(L_DEBUG, "Deferring command %s", line);
|
|
|
|
sway_log(L_DEBUG, "Deferring command %s", line);
|
|
|
|
|
|
|
|
|
|
|
|
char *cmd = malloc(strlen(line) + 1);
|
|
|
|
char *cmd = malloc(strlen(line) + 1);
|
|
|
|
strcpy(cmd, line);
|
|
|
|
strcpy(cmd, line);
|
|
|
|
list_add(config->cmd_queue, cmd);
|
|
|
|
list_add(temp_config->cmd_queue, cmd);
|
|
|
|
} else if (!temp_depth && !handle_command(config, line)) {
|
|
|
|
} else if (!temp_depth && !handle_command(temp_config, line)) {
|
|
|
|
sway_log(L_DEBUG, "Config load failed for line %s", line);
|
|
|
|
sway_log(L_DEBUG, "Config load failed for line %s", line);
|
|
|
|
success = false;
|
|
|
|
success = false;
|
|
|
|
|
|
|
|
temp_config->failed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
list_free(args);
|
|
|
|
list_free(args);
|
|
|
|
|
|
|
|
|
|
|
@ -90,15 +105,12 @@ _continue:
|
|
|
|
free(line);
|
|
|
|
free(line);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (success == false) {
|
|
|
|
|
|
|
|
exit(1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (is_active) {
|
|
|
|
if (is_active) {
|
|
|
|
config->reloading = false;
|
|
|
|
temp_config->reloading = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
config = temp_config;
|
|
|
|
|
|
|
|
|
|
|
|
return config;
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
char *do_var_replacement(struct sway_config *config, char *str) {
|
|
|
|
char *do_var_replacement(struct sway_config *config, char *str) {
|
|
|
|