diff options
Diffstat (limited to 'sway/commands/mode.c')
-rw-r--r-- | sway/commands/mode.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/sway/commands/mode.c b/sway/commands/mode.c index 189e3c1a..828d77e1 100644 --- a/sway/commands/mode.c +++ b/sway/commands/mode.c | |||
@@ -22,16 +22,14 @@ struct cmd_results *cmd_mode(int argc, char **argv) { | |||
22 | } | 22 | } |
23 | 23 | ||
24 | if (argc > 1 && !config->reading) { | 24 | if (argc > 1 && !config->reading) { |
25 | return cmd_results_new(CMD_FAILURE, | 25 | return cmd_results_new(CMD_FAILURE, "Can only be used in config file"); |
26 | "mode", "Can only be used in config file."); | ||
27 | } | 26 | } |
28 | 27 | ||
29 | bool pango = strcmp(*argv, "--pango_markup") == 0; | 28 | bool pango = strcmp(*argv, "--pango_markup") == 0; |
30 | if (pango) { | 29 | if (pango) { |
31 | argc--; argv++; | 30 | argc--; argv++; |
32 | if (argc == 0) { | 31 | if (argc == 0) { |
33 | return cmd_results_new(CMD_FAILURE, "mode", | 32 | return cmd_results_new(CMD_FAILURE, "Mode name is missing"); |
34 | "Mode name is missing"); | ||
35 | } | 33 | } |
36 | } | 34 | } |
37 | 35 | ||
@@ -50,8 +48,7 @@ struct cmd_results *cmd_mode(int argc, char **argv) { | |||
50 | if (!mode && argc > 1) { | 48 | if (!mode && argc > 1) { |
51 | mode = calloc(1, sizeof(struct sway_mode)); | 49 | mode = calloc(1, sizeof(struct sway_mode)); |
52 | if (!mode) { | 50 | if (!mode) { |
53 | return cmd_results_new(CMD_FAILURE, | 51 | return cmd_results_new(CMD_FAILURE, "Unable to allocate mode"); |
54 | "mode", "Unable to allocate mode"); | ||
55 | } | 52 | } |
56 | mode->name = strdup(mode_name); | 53 | mode->name = strdup(mode_name); |
57 | mode->keysym_bindings = create_list(); | 54 | mode->keysym_bindings = create_list(); |
@@ -61,8 +58,7 @@ struct cmd_results *cmd_mode(int argc, char **argv) { | |||
61 | list_add(config->modes, mode); | 58 | list_add(config->modes, mode); |
62 | } | 59 | } |
63 | if (!mode) { | 60 | if (!mode) { |
64 | error = cmd_results_new(CMD_INVALID, | 61 | error = cmd_results_new(CMD_INVALID, "Unknown mode `%s'", mode_name); |
65 | "mode", "Unknown mode `%s'", mode_name); | ||
66 | return error; | 62 | return error; |
67 | } | 63 | } |
68 | if ((config->reading && argc > 1) || (!config->reading && argc == 1)) { | 64 | if ((config->reading && argc > 1) || (!config->reading && argc == 1)) { |
@@ -75,7 +71,7 @@ struct cmd_results *cmd_mode(int argc, char **argv) { | |||
75 | // trigger IPC mode event | 71 | // trigger IPC mode event |
76 | ipc_event_mode(config->current_mode->name, | 72 | ipc_event_mode(config->current_mode->name, |
77 | config->current_mode->pango); | 73 | config->current_mode->pango); |
78 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 74 | return cmd_results_new(CMD_SUCCESS, NULL); |
79 | } | 75 | } |
80 | 76 | ||
81 | // Create binding | 77 | // Create binding |