summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeoffrey Casper <gcasper42@gmail.com>2020-07-04 12:28:19 -0400
committerSimon Ser <contact@emersion.fr>2020-07-15 19:27:12 +0200
commitf5ba5cbcf6b486ba8422245ed982f354ba84e2d2 (patch)
treedf9ddfe08b0b4fcb056e95efcc23f0e8a47455d0
parent585cf904c526ee8187deb238ec7728e313b3c422 (diff)
Reload command now matches i3's implementation
(cherry picked from commit ea3ba203cc65671d9bf9da5ddbc698b18ed7685c)
-rw-r--r--include/sway/config.h1
-rw-r--r--sway/commands/reload.c14
-rw-r--r--sway/config.c1
-rw-r--r--sway/sway.5.scd4
4 files changed, 17 insertions, 3 deletions
diff --git a/include/sway/config.h b/include/sway/config.h
index b3fd66681..5ad240d34 100644
--- a/include/sway/config.h
+++ b/include/sway/config.h
@@ -500,6 +500,7 @@ struct sway_config {
struct side_gaps gaps_outer;
list_t *config_chain;
+ bool user_config_path;
const char *current_config_path;
const char *current_config;
int current_config_line_number;
diff --git a/sway/commands/reload.c b/sway/commands/reload.c
index 19ec065cd..3c994d54f 100644
--- a/sway/commands/reload.c
+++ b/sway/commands/reload.c
@@ -22,7 +22,12 @@ static void do_reload(void *data) {
list_add(bar_ids, strdup(bar->id));
}
- if (!load_main_config(config->current_config_path, true, false)) {
+ const char *path = NULL;
+ if (config->user_config_path) {
+ path = config->current_config_path;
+ }
+
+ if (!load_main_config(path, true, false)) {
sway_log(SWAY_ERROR, "Error(s) reloading config");
list_free_items_and_destroy(bar_ids);
return;
@@ -55,7 +60,12 @@ struct cmd_results *cmd_reload(int argc, char **argv) {
return error;
}
- if (!load_main_config(config->current_config_path, true, true)) {
+ const char *path = NULL;
+ if (config->user_config_path) {
+ path = config->current_config_path;
+ }
+
+ if (!load_main_config(path, true, true)) {
return cmd_results_new(CMD_FAILURE, "Error(s) reloading config.");
}
diff --git a/sway/config.c b/sway/config.c
index bcf8d56fc..71382b864 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -447,6 +447,7 @@ bool load_main_config(const char *file, bool is_active, bool validating) {
}
}
+ config->user_config_path = file ? true : false;
config->current_config_path = path;
list_add(config->config_chain, real_path);
diff --git a/sway/sway.5.scd b/sway/sway.5.scd
index f4323f65e..fed4c3c77 100644
--- a/sway/sway.5.scd
+++ b/sway/sway.5.scd
@@ -272,7 +272,9 @@ set|plus|minus <amount>
optional comment argument is ignored, but logged for debugging purposes.
*reload*
- Reloads the sway config file and applies any changes.
+ Reloads the sway config file and applies any changes. The config file is
+ located at path specified by the command line arguments when started,
+ otherwise according to the priority stated in *sway*(1).
*rename workspace* [<old_name>] to <new_name>
Rename either <old_name> or the focused workspace to the <new_name>