diff options
author | Drew DeVault <sir@cmpwn.com> | 2016-03-26 11:51:59 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2016-03-26 11:51:59 -0400 |
commit | 3b849ce5a6387f2b95936ea225f2047e79a5b0c3 (patch) | |
tree | c5b8b0f46b01a681c473a82fff0d0a1412aee094 /sway/commands.c | |
parent | 3da269b78a3798f69b34b2515c7d9212e0e6827f (diff) | |
parent | 44ea92ea607e81ee6e611c6de700845effc43524 (diff) |
Merge pull request #544 from mikkeloscar/add-include-command
Add include command
Diffstat (limited to 'sway/commands.c')
-rw-r--r-- | sway/commands.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/sway/commands.c b/sway/commands.c index 26fa771e..e251f167 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -55,6 +55,7 @@ static sway_cmd cmd_font; static sway_cmd cmd_for_window; static sway_cmd cmd_fullscreen; static sway_cmd cmd_gaps; +static sway_cmd cmd_include; static sway_cmd cmd_input; static sway_cmd cmd_kill; static sway_cmd cmd_layout; @@ -1141,6 +1142,19 @@ static struct cmd_results *input_cmd_tap(int argc, char **argv) { return cmd_results_new(CMD_SUCCESS, NULL, NULL); } +static struct cmd_results *cmd_include(int argc, char **argv) { + struct cmd_results *error = NULL; + if ((error = checkarg(argc, "include", EXPECTED_EQUAL_TO, 1))) { + return error; + } + + if (!load_include_configs(argv[0], config)) { + return cmd_results_new(CMD_INVALID, "include", "Failed to include sub configuration file: %s", argv[0]); + } + + return cmd_results_new(CMD_SUCCESS, NULL, NULL); +} + static struct cmd_results *cmd_input(int argc, char **argv) { struct cmd_results *error = NULL; if ((error = checkarg(argc, "input", EXPECTED_AT_LEAST, 2))) { @@ -1541,7 +1555,9 @@ static struct cmd_results *cmd_reload(int argc, char **argv) { if ((error = checkarg(argc, "reload", EXPECTED_EQUAL_TO, 0))) { return error; } - if (!load_config(NULL)) return cmd_results_new(CMD_FAILURE, "reload", "Error(s) reloading config."); + if (!load_main_config(config->current_config, true)) { + return cmd_results_new(CMD_FAILURE, "reload", "Error(s) reloading config."); + } load_swaybars(); @@ -2053,6 +2069,7 @@ static struct cmd_handler handlers[] = { { "for_window", cmd_for_window }, { "fullscreen", cmd_fullscreen }, { "gaps", cmd_gaps }, + { "include", cmd_include }, { "input", cmd_input }, { "kill", cmd_kill }, { "layout", cmd_layout }, |