aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sway/commands.h5
-rw-r--r--sway/commands.c59
-rw-r--r--sway/commands/assign.c8
-rw-r--r--sway/commands/bar.c9
-rw-r--r--sway/commands/bar/bind.c12
-rw-r--r--sway/commands/bar/binding_mode_indicator.c5
-rw-r--r--sway/commands/bar/colors.c10
-rw-r--r--sway/commands/bar/font.c4
-rw-r--r--sway/commands/bar/gaps.c6
-rw-r--r--sway/commands/bar/height.c4
-rw-r--r--sway/commands/bar/hidden_state.c7
-rw-r--r--sway/commands/bar/icon_theme.c6
-rw-r--r--sway/commands/bar/id.c8
-rw-r--r--sway/commands/bar/mode.c6
-rw-r--r--sway/commands/bar/modifier.c8
-rw-r--r--sway/commands/bar/output.c4
-rw-r--r--sway/commands/bar/pango_markup.c4
-rw-r--r--sway/commands/bar/position.c7
-rw-r--r--sway/commands/bar/separator_symbol.c5
-rw-r--r--sway/commands/bar/status_command.c5
-rw-r--r--sway/commands/bar/status_edge_padding.c4
-rw-r--r--sway/commands/bar/status_padding.c4
-rw-r--r--sway/commands/bar/strip_workspace_name.c5
-rw-r--r--sway/commands/bar/strip_workspace_numbers.c5
-rw-r--r--sway/commands/bar/swaybar_command.c5
-rw-r--r--sway/commands/bar/tray_bindsym.c10
-rw-r--r--sway/commands/bar/tray_output.c6
-rw-r--r--sway/commands/bar/tray_padding.c10
-rw-r--r--sway/commands/bar/workspace_buttons.c5
-rw-r--r--sway/commands/bar/wrap_scroll.c4
-rw-r--r--sway/commands/bind.c29
-rw-r--r--sway/commands/border.c9
-rw-r--r--sway/commands/client.c14
-rw-r--r--sway/commands/create_output.c4
-rw-r--r--sway/commands/default_border.c4
-rw-r--r--sway/commands/default_floating_border.c4
-rw-r--r--sway/commands/default_orientation.c4
-rw-r--r--sway/commands/exec.c4
-rw-r--r--sway/commands/exec_always.c11
-rw-r--r--sway/commands/exit.c2
-rw-r--r--sway/commands/floating.c7
-rw-r--r--sway/commands/floating_minmax_size.c6
-rw-r--r--sway/commands/floating_modifier.c7
-rw-r--r--sway/commands/focus.c32
-rw-r--r--sway/commands/focus_follows_mouse.c4
-rw-r--r--sway/commands/focus_on_window_activation.c4
-rw-r--r--sway/commands/focus_wrapping.c2
-rw-r--r--sway/commands/font.c2
-rw-r--r--sway/commands/for_window.c4
-rw-r--r--sway/commands/force_display_urgency_hint.c4
-rw-r--r--sway/commands/force_focus_wrapping.c2
-rw-r--r--sway/commands/fullscreen.c6
-rw-r--r--sway/commands/gaps.c35
-rw-r--r--sway/commands/hide_edge_borders.c5
-rw-r--r--sway/commands/include.c4
-rw-r--r--sway/commands/input.c4
-rw-r--r--sway/commands/input/accel_profile.c7
-rw-r--r--sway/commands/input/click_method.c7
-rw-r--r--sway/commands/input/drag.c5
-rw-r--r--sway/commands/input/drag_lock.c5
-rw-r--r--sway/commands/input/dwt.c4
-rw-r--r--sway/commands/input/events.c9
-rw-r--r--sway/commands/input/left_handed.c5
-rw-r--r--sway/commands/input/map_from_region.c16
-rw-r--r--sway/commands/input/map_to_output.c5
-rw-r--r--sway/commands/input/middle_emulation.c5
-rw-r--r--sway/commands/input/natural_scroll.c5
-rw-r--r--sway/commands/input/pointer_accel.c10
-rw-r--r--sway/commands/input/repeat_delay.c8
-rw-r--r--sway/commands/input/repeat_rate.c8
-rw-r--r--sway/commands/input/scroll_button.c14
-rw-r--r--sway/commands/input/scroll_factor.c9
-rw-r--r--sway/commands/input/scroll_method.c7
-rw-r--r--sway/commands/input/tap.c4
-rw-r--r--sway/commands/input/tap_button_map.c7
-rw-r--r--sway/commands/input/xkb_capslock.c5
-rw-r--r--sway/commands/input/xkb_layout.c5
-rw-r--r--sway/commands/input/xkb_model.c5
-rw-r--r--sway/commands/input/xkb_numlock.c5
-rw-r--r--sway/commands/input/xkb_options.c5
-rw-r--r--sway/commands/input/xkb_rules.c5
-rw-r--r--sway/commands/input/xkb_variant.c5
-rw-r--r--sway/commands/kill.c4
-rw-r--r--sway/commands/layout.c10
-rw-r--r--sway/commands/mark.c9
-rw-r--r--sway/commands/mode.c14
-rw-r--r--sway/commands/mouse_warping.c4
-rw-r--r--sway/commands/move.c91
-rw-r--r--sway/commands/no_focus.c4
-rw-r--r--sway/commands/nop.c2
-rw-r--r--sway/commands/opacity.c6
-rw-r--r--sway/commands/output.c4
-rw-r--r--sway/commands/output/background.c17
-rw-r--r--sway/commands/output/disable.c2
-rw-r--r--sway/commands/output/dpms.c4
-rw-r--r--sway/commands/output/enable.c2
-rw-r--r--sway/commands/output/mode.c17
-rw-r--r--sway/commands/output/position.c17
-rw-r--r--sway/commands/output/scale.c7
-rw-r--r--sway/commands/output/transform.c12
-rw-r--r--sway/commands/popup_during_fullscreen.c5
-rw-r--r--sway/commands/reload.c5
-rw-r--r--sway/commands/rename.c21
-rw-r--r--sway/commands/resize.c40
-rw-r--r--sway/commands/scratchpad.c12
-rw-r--r--sway/commands/seat.c5
-rw-r--r--sway/commands/seat/attach.c6
-rw-r--r--sway/commands/seat/cursor.c30
-rw-r--r--sway/commands/seat/fallback.c4
-rw-r--r--sway/commands/seat/hide_cursor.c7
-rw-r--r--sway/commands/set.c6
-rw-r--r--sway/commands/show_marks.c2
-rw-r--r--sway/commands/smart_borders.c2
-rw-r--r--sway/commands/smart_gaps.c2
-rw-r--r--sway/commands/split.c8
-rw-r--r--sway/commands/sticky.c6
-rw-r--r--sway/commands/swap.c18
-rw-r--r--sway/commands/swaybg_command.c2
-rw-r--r--sway/commands/swaynag_command.c2
-rw-r--r--sway/commands/tiling_drag.c2
-rw-r--r--sway/commands/tiling_drag_threshold.c5
-rw-r--r--sway/commands/title_align.c4
-rw-r--r--sway/commands/title_format.c4
-rw-r--r--sway/commands/titlebar_border_thickness.c5
-rw-r--r--sway/commands/titlebar_padding.c8
-rw-r--r--sway/commands/unmark.c2
-rw-r--r--sway/commands/urgent.c7
-rw-r--r--sway/commands/workspace.c22
-rw-r--r--sway/commands/workspace_layout.c4
-rw-r--r--sway/commands/ws_auto_back_and_forth.c2
-rw-r--r--sway/commands/xwayland.c2
131 files changed, 503 insertions, 601 deletions
diff --git a/include/sway/commands.h b/include/sway/commands.h
index 757cc817..657f909e 100644
--- a/include/sway/commands.h
+++ b/include/sway/commands.h
@@ -75,7 +75,7 @@ struct cmd_results *config_commands_command(char *exec);
75/** 75/**
76 * Allocates a cmd_results object. 76 * Allocates a cmd_results object.
77 */ 77 */
78struct cmd_results *cmd_results_new(enum cmd_status status, const char* input, const char *error, ...); 78struct cmd_results *cmd_results_new(enum cmd_status status, const char *error, ...);
79/** 79/**
80 * Frees a cmd_results object. 80 * Frees a cmd_results object.
81 */ 81 */
@@ -87,8 +87,7 @@ void free_cmd_results(struct cmd_results *results);
87 */ 87 */
88char *cmd_results_to_json(list_t *res_list); 88char *cmd_results_to_json(list_t *res_list);
89 89
90struct cmd_results *add_color(const char *name, 90struct cmd_results *add_color(char *buffer, const char *color);
91 char *buffer, const char *color);
92 91
93/** 92/**
94 * TODO: Move this function and its dependent functions to container.c. 93 * TODO: Move this function and its dependent functions to container.c.
diff --git a/sway/commands.c b/sway/commands.c
index 9fae6a35..6f786035 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -36,7 +36,7 @@ struct cmd_results *checkarg(int argc, const char *name, enum expected_args type
36 } 36 }
37 } 37 }
38 return error_name ? 38 return error_name ?
39 cmd_results_new(CMD_INVALID, name, "Invalid %s command " 39 cmd_results_new(CMD_INVALID, "Invalid %s command "
40 "(expected %s%d argument%s, got %d)", 40 "(expected %s%d argument%s, got %d)",
41 name, error_name, val, val != 1 ? "s" : "", argc) 41 name, error_name, val, val != 1 ? "s" : "", argc)
42 : NULL; 42 : NULL;
@@ -228,8 +228,7 @@ list_t *execute_command(char *_exec, struct sway_seat *seat,
228 char *error = NULL; 228 char *error = NULL;
229 struct criteria *criteria = criteria_parse(head, &error); 229 struct criteria *criteria = criteria_parse(head, &error);
230 if (!criteria) { 230 if (!criteria) {
231 list_add(res_list, cmd_results_new(CMD_INVALID, head, 231 list_add(res_list, cmd_results_new(CMD_INVALID, "%s", error));
232 "%s", error));
233 free(error); 232 free(error);
234 goto cleanup; 233 goto cleanup;
235 } 234 }
@@ -265,8 +264,8 @@ list_t *execute_command(char *_exec, struct sway_seat *seat,
265 } 264 }
266 struct cmd_handler *handler = find_handler(argv[0], NULL, 0); 265 struct cmd_handler *handler = find_handler(argv[0], NULL, 0);
267 if (!handler) { 266 if (!handler) {
268 list_add(res_list, cmd_results_new(CMD_INVALID, cmd, 267 list_add(res_list, cmd_results_new(CMD_INVALID,
269 "Unknown/invalid command")); 268 "Unknown/invalid command '%s'", argv[0]));
270 free_argv(argc, argv); 269 free_argv(argc, argv);
271 goto cleanup; 270 goto cleanup;
272 } 271 }
@@ -323,20 +322,20 @@ struct cmd_results *config_command(char *exec, char **new_block) {
323 322
324 // Check for empty lines 323 // Check for empty lines
325 if (!argc) { 324 if (!argc) {
326 results = cmd_results_new(CMD_SUCCESS, NULL, NULL); 325 results = cmd_results_new(CMD_SUCCESS, NULL);
327 goto cleanup; 326 goto cleanup;
328 } 327 }
329 328
330 // Check for the start of a block 329 // Check for the start of a block
331 if (argc > 1 && strcmp(argv[argc - 1], "{") == 0) { 330 if (argc > 1 && strcmp(argv[argc - 1], "{") == 0) {
332 *new_block = join_args(argv, argc - 1); 331 *new_block = join_args(argv, argc - 1);
333 results = cmd_results_new(CMD_BLOCK, NULL, NULL); 332 results = cmd_results_new(CMD_BLOCK, NULL);
334 goto cleanup; 333 goto cleanup;
335 } 334 }
336 335
337 // Check for the end of a block 336 // Check for the end of a block
338 if (strcmp(argv[argc - 1], "}") == 0) { 337 if (strcmp(argv[argc - 1], "}") == 0) {
339 results = cmd_results_new(CMD_BLOCK_END, NULL, NULL); 338 results = cmd_results_new(CMD_BLOCK_END, NULL);
340 goto cleanup; 339 goto cleanup;
341 } 340 }
342 341
@@ -348,7 +347,7 @@ struct cmd_results *config_command(char *exec, char **new_block) {
348 argv = split_args(temp, &argc); 347 argv = split_args(temp, &argc);
349 free(temp); 348 free(temp);
350 if (!argc) { 349 if (!argc) {
351 results = cmd_results_new(CMD_SUCCESS, NULL, NULL); 350 results = cmd_results_new(CMD_SUCCESS, NULL);
352 goto cleanup; 351 goto cleanup;
353 } 352 }
354 } 353 }
@@ -357,11 +356,10 @@ struct cmd_results *config_command(char *exec, char **new_block) {
357 wlr_log(WLR_INFO, "Config command: %s", exec); 356 wlr_log(WLR_INFO, "Config command: %s", exec);
358 struct cmd_handler *handler = find_handler(argv[0], NULL, 0); 357 struct cmd_handler *handler = find_handler(argv[0], NULL, 0);
359 if (!handler || !handler->handle) { 358 if (!handler || !handler->handle) {
360 char *input = argv[0] ? argv[0] : "(empty)"; 359 const char *error = handler
361 char *error = handler 360 ? "Command '%s' is shimmed, but unimplemented"
362 ? "This command is shimmed, but unimplemented" 361 : "Unknown/invalid command '%s'";
363 : "Unknown/invalid command"; 362 results = cmd_results_new(CMD_INVALID, error, argv[0]);
364 results = cmd_results_new(CMD_INVALID, input, error);
365 goto cleanup; 363 goto cleanup;
366 } 364 }
367 365
@@ -410,14 +408,14 @@ struct cmd_results *config_subcommand(char **argv, int argc,
410 struct cmd_handler *handler = find_handler(argv[0], handlers, 408 struct cmd_handler *handler = find_handler(argv[0], handlers,
411 handlers_size); 409 handlers_size);
412 if (!handler) { 410 if (!handler) {
413 char *input = argv[0] ? argv[0] : "(empty)"; 411 return cmd_results_new(CMD_INVALID,
414 return cmd_results_new(CMD_INVALID, input, "Unknown/invalid command"); 412 "Unknown/invalid command '%s'", argv[0]);
415 } 413 }
416 if (handler->handle) { 414 if (handler->handle) {
417 return handler->handle(argc - 1, argv + 1); 415 return handler->handle(argc - 1, argv + 1);
418 } 416 }
419 return cmd_results_new(CMD_INVALID, argv[0], 417 return cmd_results_new(CMD_INVALID,
420 "This command is shimmed, but unimplemented"); 418 "The command '%s' is shimmed, but unimplemented", argv[0]);
421} 419}
422 420
423struct cmd_results *config_commands_command(char *exec) { 421struct cmd_results *config_commands_command(char *exec) {
@@ -425,7 +423,7 @@ struct cmd_results *config_commands_command(char *exec) {
425 int argc; 423 int argc;
426 char **argv = split_args(exec, &argc); 424 char **argv = split_args(exec, &argc);
427 if (!argc) { 425 if (!argc) {
428 results = cmd_results_new(CMD_SUCCESS, NULL, NULL); 426 results = cmd_results_new(CMD_SUCCESS, NULL);
429 goto cleanup; 427 goto cleanup;
430 } 428 }
431 429
@@ -433,13 +431,14 @@ struct cmd_results *config_commands_command(char *exec) {
433 char *cmd = argv[0]; 431 char *cmd = argv[0];
434 432
435 if (strcmp(cmd, "}") == 0) { 433 if (strcmp(cmd, "}") == 0) {
436 results = cmd_results_new(CMD_BLOCK_END, NULL, NULL); 434 results = cmd_results_new(CMD_BLOCK_END, NULL);
437 goto cleanup; 435 goto cleanup;
438 } 436 }
439 437
440 struct cmd_handler *handler = find_handler(cmd, NULL, 0); 438 struct cmd_handler *handler = find_handler(cmd, NULL, 0);
441 if (!handler && strcmp(cmd, "*") != 0) { 439 if (!handler && strcmp(cmd, "*") != 0) {
442 results = cmd_results_new(CMD_INVALID, cmd, "Unknown/invalid command"); 440 results = cmd_results_new(CMD_INVALID,
441 "Unknown/invalid command '%s'", cmd);
443 goto cleanup; 442 goto cleanup;
444 } 443 }
445 444
@@ -464,7 +463,7 @@ struct cmd_results *config_commands_command(char *exec) {
464 } 463 }
465 } 464 }
466 if (j == sizeof(context_names) / sizeof(context_names[0])) { 465 if (j == sizeof(context_names) / sizeof(context_names[0])) {
467 results = cmd_results_new(CMD_INVALID, cmd, 466 results = cmd_results_new(CMD_INVALID,
468 "Invalid command context %s", argv[i]); 467 "Invalid command context %s", argv[i]);
469 goto cleanup; 468 goto cleanup;
470 } 469 }
@@ -482,7 +481,7 @@ struct cmd_results *config_commands_command(char *exec) {
482 if (!policy) { 481 if (!policy) {
483 policy = alloc_command_policy(cmd); 482 policy = alloc_command_policy(cmd);
484 if (!sway_assert(policy, "Unable to allocate security policy")) { 483 if (!sway_assert(policy, "Unable to allocate security policy")) {
485 results = cmd_results_new(CMD_INVALID, cmd, 484 results = cmd_results_new(CMD_INVALID,
486 "Unable to allocate memory"); 485 "Unable to allocate memory");
487 goto cleanup; 486 goto cleanup;
488 } 487 }
@@ -493,7 +492,7 @@ struct cmd_results *config_commands_command(char *exec) {
493 wlr_log(WLR_INFO, "Set command policy for %s to %d", 492 wlr_log(WLR_INFO, "Set command policy for %s to %d",
494 policy->command, policy->context); 493 policy->command, policy->context);
495 494
496 results = cmd_results_new(CMD_SUCCESS, NULL, NULL); 495 results = cmd_results_new(CMD_SUCCESS, NULL);
497 496
498cleanup: 497cleanup:
499 free_argv(argc, argv); 498 free_argv(argc, argv);
@@ -501,14 +500,13 @@ cleanup:
501} 500}
502 501
503struct cmd_results *cmd_results_new(enum cmd_status status, 502struct cmd_results *cmd_results_new(enum cmd_status status,
504 const char *input, const char *format, ...) { 503 const char *format, ...) {
505 struct cmd_results *results = malloc(sizeof(struct cmd_results)); 504 struct cmd_results *results = malloc(sizeof(struct cmd_results));
506 if (!results) { 505 if (!results) {
507 wlr_log(WLR_ERROR, "Unable to allocate command results"); 506 wlr_log(WLR_ERROR, "Unable to allocate command results");
508 return NULL; 507 return NULL;
509 } 508 }
510 results->status = status; 509 results->status = status;
511 // NOTE: `input` argument is unused, remove
512 if (format) { 510 if (format) {
513 char *error = malloc(256); 511 char *error = malloc(256);
514 va_list args; 512 va_list args;
@@ -557,20 +555,19 @@ char *cmd_results_to_json(list_t *res_list) {
557 * 555 *
558 * return error object, or NULL if color is valid. 556 * return error object, or NULL if color is valid.
559 */ 557 */
560struct cmd_results *add_color(const char *name, 558struct cmd_results *add_color(char *buffer, const char *color) {
561 char *buffer, const char *color) {
562 int len = strlen(color); 559 int len = strlen(color);
563 if (len != 7 && len != 9) { 560 if (len != 7 && len != 9) {
564 return cmd_results_new(CMD_INVALID, name, 561 return cmd_results_new(CMD_INVALID,
565 "Invalid color definition %s", color); 562 "Invalid color definition %s", color);
566 } 563 }
567 if (color[0] != '#') { 564 if (color[0] != '#') {
568 return cmd_results_new(CMD_INVALID, name, 565 return cmd_results_new(CMD_INVALID,
569 "Invalid color definition %s", color); 566 "Invalid color definition %s", color);
570 } 567 }
571 for (int i = 1; i < len; ++i) { 568 for (int i = 1; i < len; ++i) {
572 if (!isxdigit(color[i])) { 569 if (!isxdigit(color[i])) {
573 return cmd_results_new(CMD_INVALID, name, 570 return cmd_results_new(CMD_INVALID,
574 "Invalid color definition %s", color); 571 "Invalid color definition %s", color);
575 } 572 }
576 } 573 }
diff --git a/sway/commands/assign.c b/sway/commands/assign.c
index 716d70cf..3bd1f65d 100644
--- a/sway/commands/assign.c
+++ b/sway/commands/assign.c
@@ -17,7 +17,7 @@ struct cmd_results *cmd_assign(int argc, char **argv) {
17 char *err_str = NULL; 17 char *err_str = NULL;
18 struct criteria *criteria = criteria_parse(argv[0], &err_str); 18 struct criteria *criteria = criteria_parse(argv[0], &err_str);
19 if (!criteria) { 19 if (!criteria) {
20 error = cmd_results_new(CMD_INVALID, "assign", err_str); 20 error = cmd_results_new(CMD_INVALID, err_str);
21 free(err_str); 21 free(err_str);
22 return error; 22 return error;
23 } 23 }
@@ -27,7 +27,7 @@ struct cmd_results *cmd_assign(int argc, char **argv) {
27 if (strncmp(*argv, "→", strlen("→")) == 0) { 27 if (strncmp(*argv, "→", strlen("→")) == 0) {
28 if (argc < 2) { 28 if (argc < 2) {
29 free(criteria); 29 free(criteria);
30 return cmd_results_new(CMD_INVALID, "assign", "Missing workspace"); 30 return cmd_results_new(CMD_INVALID, "Missing workspace");
31 } 31 }
32 --argc; 32 --argc;
33 ++argv; 33 ++argv;
@@ -44,7 +44,7 @@ struct cmd_results *cmd_assign(int argc, char **argv) {
44 --argc; ++argv; 44 --argc; ++argv;
45 if (argv[0][0] < '0' || argv[0][0] > '9') { 45 if (argv[0][0] < '0' || argv[0][0] > '9') {
46 free(criteria); 46 free(criteria);
47 return cmd_results_new(CMD_INVALID, "assign", 47 return cmd_results_new(CMD_INVALID,
48 "Invalid workspace number '%s'", argv[0]); 48 "Invalid workspace number '%s'", argv[0]);
49 } 49 }
50 criteria->type = CT_ASSIGN_WORKSPACE_NUMBER; 50 criteria->type = CT_ASSIGN_WORKSPACE_NUMBER;
@@ -59,5 +59,5 @@ struct cmd_results *cmd_assign(int argc, char **argv) {
59 wlr_log(WLR_DEBUG, "assign: '%s' -> '%s' added", criteria->raw, 59 wlr_log(WLR_DEBUG, "assign: '%s' -> '%s' added", criteria->raw,
60 criteria->target); 60 criteria->target);
61 61
62 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 62 return cmd_results_new(CMD_SUCCESS, NULL);
63} 63}
diff --git a/sway/commands/bar.c b/sway/commands/bar.c
index 2a82d508..b19d9574 100644
--- a/sway/commands/bar.c
+++ b/sway/commands/bar.c
@@ -69,7 +69,7 @@ struct cmd_results *cmd_bar(int argc, char **argv) {
69 wlr_log(WLR_DEBUG, "Creating bar: %s", argv[0]); 69 wlr_log(WLR_DEBUG, "Creating bar: %s", argv[0]);
70 bar = default_bar_config(); 70 bar = default_bar_config();
71 if (!bar) { 71 if (!bar) {
72 return cmd_results_new(CMD_FAILURE, "bar", 72 return cmd_results_new(CMD_FAILURE,
73 "Unable to allocate bar state"); 73 "Unable to allocate bar state");
74 } 74 }
75 75
@@ -83,7 +83,7 @@ struct cmd_results *cmd_bar(int argc, char **argv) {
83 // Create new bar with default values 83 // Create new bar with default values
84 struct bar_config *bar = default_bar_config(); 84 struct bar_config *bar = default_bar_config();
85 if (!bar) { 85 if (!bar) {
86 return cmd_results_new(CMD_FAILURE, "bar", 86 return cmd_results_new(CMD_FAILURE,
87 "Unable to allocate bar state"); 87 "Unable to allocate bar state");
88 } 88 }
89 89
@@ -93,8 +93,7 @@ struct cmd_results *cmd_bar(int argc, char **argv) {
93 if (bar->id) { 93 if (bar->id) {
94 snprintf(bar->id, len, "bar-%d", config->bars->length - 1); 94 snprintf(bar->id, len, "bar-%d", config->bars->length - 1);
95 } else { 95 } else {
96 return cmd_results_new(CMD_FAILURE, 96 return cmd_results_new(CMD_FAILURE, "Unable to allocate bar ID");
97 "bar", "Unable to allocate bar ID");
98 } 97 }
99 98
100 // Set current bar 99 // Set current bar
@@ -117,7 +116,7 @@ struct cmd_results *cmd_bar(int argc, char **argv) {
117 } 116 }
118 } 117 }
119 } 118 }
120 return cmd_results_new(CMD_INVALID, "bar", 119 return cmd_results_new(CMD_INVALID,
121 "Can only be used in the config file."); 120 "Can only be used in the config file.");
122 } 121 }
123 122
diff --git a/sway/commands/bar/bind.c b/sway/commands/bar/bind.c
index a4c65ec4..71adced8 100644
--- a/sway/commands/bar/bind.c
+++ b/sway/commands/bar/bind.c
@@ -16,13 +16,12 @@ static struct cmd_results *bar_cmd_bind(int argc, char **argv, bool code) {
16 return error; 16 return error;
17 } 17 }
18 if (!config->current_bar) { 18 if (!config->current_bar) {
19 return cmd_results_new(CMD_FAILURE, command, "No bar defined."); 19 return cmd_results_new(CMD_FAILURE, "No bar defined.");
20 } 20 }
21 21
22 struct bar_binding *binding = calloc(1, sizeof(struct bar_binding)); 22 struct bar_binding *binding = calloc(1, sizeof(struct bar_binding));
23 if (!binding) { 23 if (!binding) {
24 return cmd_results_new(CMD_FAILURE, command, 24 return cmd_results_new(CMD_FAILURE, "Unable to allocate bar binding");
25 "Unable to allocate bar binding");
26 } 25 }
27 26
28 binding->release = false; 27 binding->release = false;
@@ -40,13 +39,12 @@ static struct cmd_results *bar_cmd_bind(int argc, char **argv, bool code) {
40 } 39 }
41 if (message) { 40 if (message) {
42 free_bar_binding(binding); 41 free_bar_binding(binding);
43 error = cmd_results_new(CMD_INVALID, command, message); 42 error = cmd_results_new(CMD_INVALID, message);
44 free(message); 43 free(message);
45 return error; 44 return error;
46 } else if (!binding->button) { 45 } else if (!binding->button) {
47 free_bar_binding(binding); 46 free_bar_binding(binding);
48 return cmd_results_new(CMD_INVALID, command, 47 return cmd_results_new(CMD_INVALID, "Unknown button %s", argv[0]);
49 "Unknown button %s", argv[0]);
50 } 48 }
51 49
52 const char *name = libevdev_event_code_get_name(EV_KEY, binding->button); 50 const char *name = libevdev_event_code_get_name(EV_KEY, binding->button);
@@ -94,7 +92,7 @@ static struct cmd_results *bar_cmd_bind(int argc, char **argv, bool code) {
94 binding->release ? " - release" : ""); 92 binding->release ? " - release" : "");
95 } 93 }
96 94
97 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 95 return cmd_results_new(CMD_SUCCESS, NULL);
98} 96}
99 97
100struct cmd_results *bar_cmd_bindcode(int argc, char **argv) { 98struct cmd_results *bar_cmd_bindcode(int argc, char **argv) {
diff --git a/sway/commands/bar/binding_mode_indicator.c b/sway/commands/bar/binding_mode_indicator.c
index b048b7b9..15acc309 100644
--- a/sway/commands/bar/binding_mode_indicator.c
+++ b/sway/commands/bar/binding_mode_indicator.c
@@ -11,8 +11,7 @@ struct cmd_results *bar_cmd_binding_mode_indicator(int argc, char **argv) {
11 return error; 11 return error;
12 } 12 }
13 if (!config->current_bar) { 13 if (!config->current_bar) {
14 return cmd_results_new(CMD_FAILURE, 14 return cmd_results_new(CMD_FAILURE, "No bar defined.");
15 "binding_mode_indicator", "No bar defined.");
16 } 15 }
17 config->current_bar->binding_mode_indicator = 16 config->current_bar->binding_mode_indicator =
18 parse_boolean(argv[0], config->current_bar->binding_mode_indicator); 17 parse_boolean(argv[0], config->current_bar->binding_mode_indicator);
@@ -23,5 +22,5 @@ struct cmd_results *bar_cmd_binding_mode_indicator(int argc, char **argv) {
23 wlr_log(WLR_DEBUG, "Disabling binding mode indicator on bar: %s", 22 wlr_log(WLR_DEBUG, "Disabling binding mode indicator on bar: %s",
24 config->current_bar->id); 23 config->current_bar->id);
25 } 24 }
26 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 25 return cmd_results_new(CMD_SUCCESS, NULL);
27} 26}
diff --git a/sway/commands/bar/colors.c b/sway/commands/bar/colors.c
index ebf1e3e1..7921db0d 100644
--- a/sway/commands/bar/colors.c
+++ b/sway/commands/bar/colors.c
@@ -25,11 +25,11 @@ static struct cmd_results *parse_single_color(char **color,
25 if (!*color && !(*color = malloc(10))) { 25 if (!*color && !(*color = malloc(10))) {
26 return NULL; 26 return NULL;
27 } 27 }
28 error = add_color(cmd_name, *color, argv[0]); 28 error = add_color(*color, argv[0]);
29 if (error) { 29 if (error) {
30 return error; 30 return error;
31 } 31 }
32 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 32 return cmd_results_new(CMD_SUCCESS, NULL);
33} 33}
34 34
35static struct cmd_results *parse_three_colors(char ***colors, 35static struct cmd_results *parse_three_colors(char ***colors,
@@ -37,18 +37,18 @@ static struct cmd_results *parse_three_colors(char ***colors,
37 struct cmd_results *error = NULL; 37 struct cmd_results *error = NULL;
38 if (argc != 3) { 38 if (argc != 3) {
39 return cmd_results_new(CMD_INVALID, 39 return cmd_results_new(CMD_INVALID,
40 cmd_name, "Requires exactly three color values"); 40 "Command '%s' requires exactly three color values", cmd_name);
41 } 41 }
42 for (size_t i = 0; i < 3; i++) { 42 for (size_t i = 0; i < 3; i++) {
43 if (!*colors[i] && !(*(colors[i]) = malloc(10))) { 43 if (!*colors[i] && !(*(colors[i]) = malloc(10))) {
44 return NULL; 44 return NULL;
45 } 45 }
46 error = add_color(cmd_name, *(colors[i]), argv[i]); 46 error = add_color(*(colors[i]), argv[i]);
47 if (error) { 47 if (error) {
48 return error; 48 return error;
49 } 49 }
50 } 50 }
51 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 51 return cmd_results_new(CMD_SUCCESS, NULL);
52} 52}
53 53
54struct cmd_results *bar_cmd_colors(int argc, char **argv) { 54struct cmd_results *bar_cmd_colors(int argc, char **argv) {
diff --git a/sway/commands/bar/font.c b/sway/commands/bar/font.c
index 2aa4e895..c6147e3d 100644
--- a/sway/commands/bar/font.c
+++ b/sway/commands/bar/font.c
@@ -10,12 +10,12 @@ struct cmd_results *bar_cmd_font(int argc, char **argv) {
10 return error; 10 return error;
11 } 11 }
12 if (!config->current_bar) { 12 if (!config->current_bar) {
13 return cmd_results_new(CMD_FAILURE, "font", "No bar defined."); 13 return cmd_results_new(CMD_FAILURE, "No bar defined.");
14 } 14 }
15 char *font = join_args(argv, argc); 15 char *font = join_args(argv, argc);
16 free(config->current_bar->font); 16 free(config->current_bar->font);
17 config->current_bar->font = font; 17 config->current_bar->font = font;
18 wlr_log(WLR_DEBUG, "Settings font '%s' for bar: %s", 18 wlr_log(WLR_DEBUG, "Settings font '%s' for bar: %s",
19 config->current_bar->font, config->current_bar->id); 19 config->current_bar->font, config->current_bar->id);
20 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 20 return cmd_results_new(CMD_SUCCESS, NULL);
21} 21}
diff --git a/sway/commands/bar/gaps.c b/sway/commands/bar/gaps.c
index f78f3742..fabe12fc 100644
--- a/sway/commands/bar/gaps.c
+++ b/sway/commands/bar/gaps.c
@@ -14,7 +14,7 @@ struct cmd_results *bar_cmd_gaps(int argc, char **argv) {
14 return error; 14 return error;
15 } 15 }
16 if (!config->current_bar) { 16 if (!config->current_bar) {
17 return cmd_results_new(CMD_FAILURE, "bar gaps", "No bar defined."); 17 return cmd_results_new(CMD_FAILURE, "No bar defined.");
18 } 18 }
19 19
20 int top = 0, right = 0, bottom = 0, left = 0; 20 int top = 0, right = 0, bottom = 0, left = 0;
@@ -23,7 +23,7 @@ struct cmd_results *bar_cmd_gaps(int argc, char **argv) {
23 char *end; 23 char *end;
24 int amount = strtol(argv[i], &end, 10); 24 int amount = strtol(argv[i], &end, 10);
25 if (strlen(end) && strcasecmp(end, "px") != 0) { 25 if (strlen(end) && strcasecmp(end, "px") != 0) {
26 return cmd_results_new(CMD_INVALID, "bar gaps", 26 return cmd_results_new(CMD_INVALID,
27 "Expected 'bar [<bar-id>] gaps <all> | <horizonal> " 27 "Expected 'bar [<bar-id>] gaps <all> | <horizonal> "
28 "<vertical> | <top> <right> <bottom> <left>'"); 28 "<vertical> | <top> <right> <bottom> <left>'");
29 } 29 }
@@ -56,5 +56,5 @@ struct cmd_results *bar_cmd_gaps(int argc, char **argv) {
56 ipc_event_barconfig_update(config->current_bar); 56 ipc_event_barconfig_update(config->current_bar);
57 } 57 }
58 58
59 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 59 return cmd_results_new(CMD_SUCCESS, NULL);
60} 60}
diff --git a/sway/commands/bar/height.c b/sway/commands/bar/height.c
index 18258526..a2e72533 100644
--- a/sway/commands/bar/height.c
+++ b/sway/commands/bar/height.c
@@ -10,11 +10,11 @@ struct cmd_results *bar_cmd_height(int argc, char **argv) {
10 } 10 }
11 int height = atoi(argv[0]); 11 int height = atoi(argv[0]);
12 if (height < 0) { 12 if (height < 0) {
13 return cmd_results_new(CMD_INVALID, "height", 13 return cmd_results_new(CMD_INVALID,
14 "Invalid height value: %s", argv[0]); 14 "Invalid height value: %s", argv[0]);
15 } 15 }
16 config->current_bar->height = height; 16 config->current_bar->height = height;
17 wlr_log(WLR_DEBUG, "Setting bar height to %d on bar: %s", 17 wlr_log(WLR_DEBUG, "Setting bar height to %d on bar: %s",
18 height, config->current_bar->id); 18 height, config->current_bar->id);
19 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 19 return cmd_results_new(CMD_SUCCESS, NULL);
20} 20}
diff --git a/sway/commands/bar/hidden_state.c b/sway/commands/bar/hidden_state.c
index 79eaf01c..3364ce70 100644
--- a/sway/commands/bar/hidden_state.c
+++ b/sway/commands/bar/hidden_state.c
@@ -20,8 +20,7 @@ static struct cmd_results *bar_set_hidden_state(struct bar_config *bar,
20 } else if (strcasecmp("show", hidden_state) == 0) { 20 } else if (strcasecmp("show", hidden_state) == 0) {
21 bar->hidden_state = strdup("show"); 21 bar->hidden_state = strdup("show");
22 } else { 22 } else {
23 return cmd_results_new(CMD_INVALID, "hidden_state", 23 return cmd_results_new(CMD_INVALID, "Invalid value %s", hidden_state);
24 "Invalid value %s", hidden_state);
25 } 24 }
26 if (strcmp(old_state, bar->hidden_state) != 0) { 25 if (strcmp(old_state, bar->hidden_state) != 0) {
27 if (!config->reading) { 26 if (!config->reading) {
@@ -44,7 +43,7 @@ struct cmd_results *bar_cmd_hidden_state(int argc, char **argv) {
44 return error; 43 return error;
45 } 44 }
46 if (config->reading && argc > 1) { 45 if (config->reading && argc > 1) {
47 return cmd_results_new(CMD_INVALID, "hidden_state", 46 return cmd_results_new(CMD_INVALID,
48 "Unexpected value %s in config mode", argv[1]); 47 "Unexpected value %s in config mode", argv[1]);
49 } 48 }
50 49
@@ -65,5 +64,5 @@ struct cmd_results *bar_cmd_hidden_state(int argc, char **argv) {
65 } 64 }
66 } 65 }
67 } 66 }
68 return error ? error : cmd_results_new(CMD_SUCCESS, NULL, NULL); 67 return error ? error : cmd_results_new(CMD_SUCCESS, NULL);
69} 68}
diff --git a/sway/commands/bar/icon_theme.c b/sway/commands/bar/icon_theme.c
index 9d3b6040..2d16f748 100644
--- a/sway/commands/bar/icon_theme.c
+++ b/sway/commands/bar/icon_theme.c
@@ -13,16 +13,16 @@ struct cmd_results *bar_cmd_icon_theme(int argc, char **argv) {
13 } 13 }
14 14
15 if (!config->current_bar) { 15 if (!config->current_bar) {
16 return cmd_results_new(CMD_FAILURE, "tray_padding", "No bar defined."); 16 return cmd_results_new(CMD_FAILURE, "No bar defined.");
17 } 17 }
18 18
19 wlr_log(WLR_DEBUG, "[Bar %s] Setting icon theme to %s", 19 wlr_log(WLR_DEBUG, "[Bar %s] Setting icon theme to %s",
20 config->current_bar->id, argv[0]); 20 config->current_bar->id, argv[0]);
21 free(config->current_bar->icon_theme); 21 free(config->current_bar->icon_theme);
22 config->current_bar->icon_theme = strdup(argv[0]); 22 config->current_bar->icon_theme = strdup(argv[0]);
23 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 23 return cmd_results_new(CMD_SUCCESS, NULL);
24#else 24#else
25 return cmd_results_new(CMD_INVALID, "icon_theme", 25 return cmd_results_new(CMD_INVALID,
26 "Sway has been compiled without tray support"); 26 "Sway has been compiled without tray support");
27#endif 27#endif
28} 28}
diff --git a/sway/commands/bar/id.c b/sway/commands/bar/id.c
index 35509459..bef3023b 100644
--- a/sway/commands/bar/id.c
+++ b/sway/commands/bar/id.c
@@ -12,15 +12,15 @@ struct cmd_results *bar_cmd_id(int argc, char **argv) {
12 const char *name = argv[0]; 12 const char *name = argv[0];
13 const char *oldname = config->current_bar->id; 13 const char *oldname = config->current_bar->id;
14 if (strcmp(name, oldname) == 0) { 14 if (strcmp(name, oldname) == 0) {
15 return cmd_results_new(CMD_SUCCESS, NULL, NULL); // NOP 15 return cmd_results_new(CMD_SUCCESS, NULL); // NOP
16 } else if (strcmp(name, "id") == 0) { 16 } else if (strcmp(name, "id") == 0) {
17 return cmd_results_new(CMD_INVALID, "id", "id cannot be 'id'"); 17 return cmd_results_new(CMD_INVALID, "id cannot be 'id'");
18 } 18 }
19 // check if id is used by a previously defined bar 19 // check if id is used by a previously defined bar
20 for (int i = 0; i < config->bars->length; ++i) { 20 for (int i = 0; i < config->bars->length; ++i) {
21 struct bar_config *find = config->bars->items[i]; 21 struct bar_config *find = config->bars->items[i];
22 if (strcmp(name, find->id) == 0 && config->current_bar != find) { 22 if (strcmp(name, find->id) == 0 && config->current_bar != find) {
23 return cmd_results_new(CMD_FAILURE, "id", 23 return cmd_results_new(CMD_FAILURE,
24 "Id '%s' already defined for another bar. Id unchanged (%s).", 24 "Id '%s' already defined for another bar. Id unchanged (%s).",
25 name, oldname); 25 name, oldname);
26 } 26 }
@@ -31,5 +31,5 @@ struct cmd_results *bar_cmd_id(int argc, char **argv) {
31 // free old bar id 31 // free old bar id
32 free(config->current_bar->id); 32 free(config->current_bar->id);
33 config->current_bar->id = strdup(name); 33 config->current_bar->id = strdup(name);
34 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 34 return cmd_results_new(CMD_SUCCESS, NULL);
35} 35}
diff --git a/sway/commands/bar/mode.c b/sway/commands/bar/mode.c
index dcaf6da9..1698db8d 100644
--- a/sway/commands/bar/mode.c
+++ b/sway/commands/bar/mode.c
@@ -21,7 +21,7 @@ static struct cmd_results *bar_set_mode(struct bar_config *bar, const char *mode
21 } else if (strcasecmp("invisible", mode) == 0) { 21 } else if (strcasecmp("invisible", mode) == 0) {
22 bar->mode = strdup("invisible"); 22 bar->mode = strdup("invisible");
23 } else { 23 } else {
24 return cmd_results_new(CMD_INVALID, "mode", "Invalid value %s", mode); 24 return cmd_results_new(CMD_INVALID, "Invalid value %s", mode);
25 } 25 }
26 26
27 if (strcmp(old_mode, bar->mode) != 0) { 27 if (strcmp(old_mode, bar->mode) != 0) {
@@ -46,7 +46,7 @@ struct cmd_results *bar_cmd_mode(int argc, char **argv) {
46 } 46 }
47 if (config->reading && argc > 1) { 47 if (config->reading && argc > 1) {
48 return cmd_results_new(CMD_INVALID, 48 return cmd_results_new(CMD_INVALID,
49 "mode", "Unexpected value %s in config mode", argv[1]); 49 "Unexpected value %s in config mode", argv[1]);
50 } 50 }
51 51
52 const char *mode = argv[0]; 52 const char *mode = argv[0];
@@ -66,5 +66,5 @@ struct cmd_results *bar_cmd_mode(int argc, char **argv) {
66 } 66 }
67 } 67 }
68 } 68 }
69 return error ? error : cmd_results_new(CMD_SUCCESS, NULL, NULL); 69 return error ? error : cmd_results_new(CMD_SUCCESS, NULL);
70} 70}
diff --git a/sway/commands/bar/modifier.c b/sway/commands/bar/modifier.c
index b5a16f45..0d28d6a2 100644
--- a/sway/commands/bar/modifier.c
+++ b/sway/commands/bar/modifier.c
@@ -11,7 +11,7 @@ struct cmd_results *bar_cmd_modifier(int argc, char **argv) {
11 } 11 }
12 12
13 if (!config->current_bar) { 13 if (!config->current_bar) {
14 return cmd_results_new(CMD_FAILURE, "modifier", "No bar defined."); 14 return cmd_results_new(CMD_FAILURE, "No bar defined.");
15 } 15 }
16 16
17 uint32_t mod = 0; 17 uint32_t mod = 0;
@@ -21,8 +21,8 @@ struct cmd_results *bar_cmd_modifier(int argc, char **argv) {
21 if ((tmp_mod = get_modifier_mask_by_name(split->items[i])) > 0) { 21 if ((tmp_mod = get_modifier_mask_by_name(split->items[i])) > 0) {
22 mod |= tmp_mod; 22 mod |= tmp_mod;
23 } else { 23 } else {
24 error = cmd_results_new(CMD_INVALID, "modifier", 24 error = cmd_results_new(CMD_INVALID,
25 "Unknown modifier '%s'", split->items[i]); 25 "Unknown modifier '%s'", (char *)split->items[i]);
26 list_free_items_and_destroy(split); 26 list_free_items_and_destroy(split);
27 return error; 27 return error;
28 } 28 }
@@ -31,5 +31,5 @@ struct cmd_results *bar_cmd_modifier(int argc, char **argv) {
31 config->current_bar->modifier = mod; 31 config->current_bar->modifier = mod;
32 wlr_log(WLR_DEBUG, 32 wlr_log(WLR_DEBUG,
33 "Show/Hide the bar when pressing '%s' in hide mode.", argv[0]); 33 "Show/Hide the bar when pressing '%s' in hide mode.", argv[0]);
34 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 34 return cmd_results_new(CMD_SUCCESS, NULL);
35} 35}
diff --git a/sway/commands/bar/output.c b/sway/commands/bar/output.c
index 930d779d..9ad10678 100644
--- a/sway/commands/bar/output.c
+++ b/sway/commands/bar/output.c
@@ -11,7 +11,7 @@ struct cmd_results *bar_cmd_output(int argc, char **argv) {
11 return error; 11 return error;
12 } 12 }
13 if (!config->current_bar) { 13 if (!config->current_bar) {
14 return cmd_results_new(CMD_FAILURE, "output", "No bar defined."); 14 return cmd_results_new(CMD_FAILURE, "No bar defined.");
15 } 15 }
16 16
17 const char *output = argv[0]; 17 const char *output = argv[0];
@@ -45,5 +45,5 @@ struct cmd_results *bar_cmd_output(int argc, char **argv) {
45 wlr_log(WLR_DEBUG, "Adding bar: '%s' to output '%s'", 45 wlr_log(WLR_DEBUG, "Adding bar: '%s' to output '%s'",
46 config->current_bar->id, output); 46 config->current_bar->id, output);
47 } 47 }
48 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 48 return cmd_results_new(CMD_SUCCESS, NULL);
49} 49}
diff --git a/sway/commands/bar/pango_markup.c b/sway/commands/bar/pango_markup.c
index d57cc45c..0ffa41d9 100644
--- a/sway/commands/bar/pango_markup.c
+++ b/sway/commands/bar/pango_markup.c
@@ -10,7 +10,7 @@ struct cmd_results *bar_cmd_pango_markup(int argc, char **argv) {
10 return error; 10 return error;
11 } 11 }
12 if (!config->current_bar) { 12 if (!config->current_bar) {
13 return cmd_results_new(CMD_FAILURE, "pango_markup", "No bar defined."); 13 return cmd_results_new(CMD_FAILURE, "No bar defined.");
14 } 14 }
15 config->current_bar->pango_markup 15 config->current_bar->pango_markup
16 = parse_boolean(argv[0], config->current_bar->pango_markup); 16 = parse_boolean(argv[0], config->current_bar->pango_markup);
@@ -21,5 +21,5 @@ struct cmd_results *bar_cmd_pango_markup(int argc, char **argv) {
21 wlr_log(WLR_DEBUG, "Disabling pango markup for bar: %s", 21 wlr_log(WLR_DEBUG, "Disabling pango markup for bar: %s",
22 config->current_bar->id); 22 config->current_bar->id);
23 } 23 }
24 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 24 return cmd_results_new(CMD_SUCCESS, NULL);
25} 25}
diff --git a/sway/commands/bar/position.c b/sway/commands/bar/position.c
index 2870f60f..2e3f79b4 100644
--- a/sway/commands/bar/position.c
+++ b/sway/commands/bar/position.c
@@ -10,7 +10,7 @@ struct cmd_results *bar_cmd_position(int argc, char **argv) {
10 return error; 10 return error;
11 } 11 }
12 if (!config->current_bar) { 12 if (!config->current_bar) {
13 return cmd_results_new(CMD_FAILURE, "position", "No bar defined."); 13 return cmd_results_new(CMD_FAILURE, "No bar defined.");
14 } 14 }
15 char *valid[] = { "top", "bottom" }; 15 char *valid[] = { "top", "bottom" };
16 for (size_t i = 0; i < sizeof(valid) / sizeof(valid[0]); ++i) { 16 for (size_t i = 0; i < sizeof(valid) / sizeof(valid[0]); ++i) {
@@ -19,9 +19,8 @@ struct cmd_results *bar_cmd_position(int argc, char **argv) {
19 argv[0], config->current_bar->id); 19 argv[0], config->current_bar->id);
20 free(config->current_bar->position); 20 free(config->current_bar->position);
21 config->current_bar->position = strdup(argv[0]); 21 config->current_bar->position = strdup(argv[0]);
22 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 22 return cmd_results_new(CMD_SUCCESS, NULL);
23 } 23 }
24 } 24 }
25 return cmd_results_new(CMD_INVALID, 25 return cmd_results_new(CMD_INVALID, "Invalid value %s", argv[0]);
26 "position", "Invalid value %s", argv[0]);
27} 26}
diff --git a/sway/commands/bar/separator_symbol.c b/sway/commands/bar/separator_symbol.c
index 060b8f52..145cdea5 100644
--- a/sway/commands/bar/separator_symbol.c
+++ b/sway/commands/bar/separator_symbol.c
@@ -9,12 +9,11 @@ struct cmd_results *bar_cmd_separator_symbol(int argc, char **argv) {
9 return error; 9 return error;
10 } 10 }
11 if (!config->current_bar) { 11 if (!config->current_bar) {
12 return cmd_results_new(CMD_FAILURE, 12 return cmd_results_new(CMD_FAILURE, "No bar defined.");
13 "separator_symbol", "No bar defined.");
14 } 13 }
15 free(config->current_bar->separator_symbol); 14 free(config->current_bar->separator_symbol);
16 config->current_bar->separator_symbol = strdup(argv[0]); 15 config->current_bar->separator_symbol = strdup(argv[0]);
17 wlr_log(WLR_DEBUG, "Settings separator_symbol '%s' for bar: %s", 16 wlr_log(WLR_DEBUG, "Settings separator_symbol '%s' for bar: %s",
18 config->current_bar->separator_symbol, config->current_bar->id); 17 config->current_bar->separator_symbol, config->current_bar->id);
19 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 18 return cmd_results_new(CMD_SUCCESS, NULL);
20} 19}
diff --git a/sway/commands/bar/status_command.c b/sway/commands/bar/status_command.c
index 490393f1..c379cc72 100644
--- a/sway/commands/bar/status_command.c
+++ b/sway/commands/bar/status_command.c
@@ -9,8 +9,7 @@ struct cmd_results *bar_cmd_status_command(int argc, char **argv) {
9 return error; 9 return error;
10 } 10 }
11 if (!config->current_bar) { 11 if (!config->current_bar) {
12 return cmd_results_new(CMD_FAILURE, 12 return cmd_results_new(CMD_FAILURE, "No bar defined.");
13 "status_command", "No bar defined.");
14 } 13 }
15 free(config->current_bar->status_command); 14 free(config->current_bar->status_command);
16 config->current_bar->status_command = NULL; 15 config->current_bar->status_command = NULL;
@@ -28,5 +27,5 @@ struct cmd_results *bar_cmd_status_command(int argc, char **argv) {
28 load_swaybar(config->current_bar); 27 load_swaybar(config->current_bar);
29 } 28 }
30 29
31 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 30 return cmd_results_new(CMD_SUCCESS, NULL);
32} 31}
diff --git a/sway/commands/bar/status_edge_padding.c b/sway/commands/bar/status_edge_padding.c
index f3b10631..565ab9a9 100644
--- a/sway/commands/bar/status_edge_padding.c
+++ b/sway/commands/bar/status_edge_padding.c
@@ -11,11 +11,11 @@ struct cmd_results *bar_cmd_status_edge_padding(int argc, char **argv) {
11 char *end; 11 char *end;
12 int padding = strtol(argv[0], &end, 10); 12 int padding = strtol(argv[0], &end, 10);
13 if (strlen(end) || padding < 0) { 13 if (strlen(end) || padding < 0) {
14 return cmd_results_new(CMD_INVALID, "status_edge_padding", 14 return cmd_results_new(CMD_INVALID,
15 "Padding must be a positive integer"); 15 "Padding must be a positive integer");
16 } 16 }
17 config->current_bar->status_edge_padding = padding; 17 config->current_bar->status_edge_padding = padding;
18 wlr_log(WLR_DEBUG, "Status edge padding on bar %s: %d", 18 wlr_log(WLR_DEBUG, "Status edge padding on bar %s: %d",
19 config->current_bar->id, config->current_bar->status_edge_padding); 19 config->current_bar->id, config->current_bar->status_edge_padding);
20 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 20 return cmd_results_new(CMD_SUCCESS, NULL);
21} 21}
diff --git a/sway/commands/bar/status_padding.c b/sway/commands/bar/status_padding.c
index 13b8eb6b..7a69a25d 100644
--- a/sway/commands/bar/status_padding.c
+++ b/sway/commands/bar/status_padding.c
@@ -11,11 +11,11 @@ struct cmd_results *bar_cmd_status_padding(int argc, char **argv) {
11 char *end; 11 char *end;
12 int padding = strtol(argv[0], &end, 10); 12 int padding = strtol(argv[0], &end, 10);
13 if (strlen(end) || padding < 0) { 13 if (strlen(end) || padding < 0) {
14 return cmd_results_new(CMD_INVALID, "status_padding", 14 return cmd_results_new(CMD_INVALID,
15 "Padding must be a positive integer"); 15 "Padding must be a positive integer");
16 } 16 }
17 config->current_bar->status_padding = padding; 17 config->current_bar->status_padding = padding;
18 wlr_log(WLR_DEBUG, "Status padding on bar %s: %d", 18 wlr_log(WLR_DEBUG, "Status padding on bar %s: %d",
19 config->current_bar->id, config->current_bar->status_padding); 19 config->current_bar->id, config->current_bar->status_padding);
20 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 20 return cmd_results_new(CMD_SUCCESS, NULL);
21} 21}
diff --git a/sway/commands/bar/strip_workspace_name.c b/sway/commands/bar/strip_workspace_name.c
index 79692f6e..b74afd6e 100644
--- a/sway/commands/bar/strip_workspace_name.c
+++ b/sway/commands/bar/strip_workspace_name.c
@@ -11,8 +11,7 @@ struct cmd_results *bar_cmd_strip_workspace_name(int argc, char **argv) {
11 return error; 11 return error;
12 } 12 }
13 if (!config->current_bar) { 13 if (!config->current_bar) {
14 return cmd_results_new(CMD_FAILURE, 14 return cmd_results_new(CMD_FAILURE, "No bar defined.");
15 "strip_workspace_name", "No bar defined.");
16 } 15 }
17 16
18 config->current_bar->strip_workspace_name = 17 config->current_bar->strip_workspace_name =
@@ -28,5 +27,5 @@ struct cmd_results *bar_cmd_strip_workspace_name(int argc, char **argv) {
28 config->current_bar->id); 27 config->current_bar->id);
29 } 28 }
30 29
31 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 30 return cmd_results_new(CMD_SUCCESS, NULL);
32} 31}
diff --git a/sway/commands/bar/strip_workspace_numbers.c b/sway/commands/bar/strip_workspace_numbers.c
index b33d01e5..9c6ec228 100644
--- a/sway/commands/bar/strip_workspace_numbers.c
+++ b/sway/commands/bar/strip_workspace_numbers.c
@@ -11,8 +11,7 @@ struct cmd_results *bar_cmd_strip_workspace_numbers(int argc, char **argv) {
11 return error; 11 return error;
12 } 12 }
13 if (!config->current_bar) { 13 if (!config->current_bar) {
14 return cmd_results_new(CMD_FAILURE, 14 return cmd_results_new(CMD_FAILURE, "No bar defined.");
15 "strip_workspace_numbers", "No bar defined.");
16 } 15 }
17 16
18 config->current_bar->strip_workspace_numbers = 17 config->current_bar->strip_workspace_numbers =
@@ -28,5 +27,5 @@ struct cmd_results *bar_cmd_strip_workspace_numbers(int argc, char **argv) {
28 config->current_bar->id); 27 config->current_bar->id);
29 } 28 }
30 29
31 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 30 return cmd_results_new(CMD_SUCCESS, NULL);
32} 31}
diff --git a/sway/commands/bar/swaybar_command.c b/sway/commands/bar/swaybar_command.c
index 04e78e77..6253e2b1 100644
--- a/sway/commands/bar/swaybar_command.c
+++ b/sway/commands/bar/swaybar_command.c
@@ -9,12 +9,11 @@ struct cmd_results *bar_cmd_swaybar_command(int argc, char **argv) {
9 return error; 9 return error;
10 } 10 }
11 if (!config->current_bar) { 11 if (!config->current_bar) {
12 return cmd_results_new(CMD_FAILURE, 12 return cmd_results_new(CMD_FAILURE, "No bar defined.");
13 "swaybar_command", "No bar defined.");
14 } 13 }
15 free(config->current_bar->swaybar_command); 14 free(config->current_bar->swaybar_command);
16 config->current_bar->swaybar_command = join_args(argv, argc); 15 config->current_bar->swaybar_command = join_args(argv, argc);
17 wlr_log(WLR_DEBUG, "Using custom swaybar command: %s", 16 wlr_log(WLR_DEBUG, "Using custom swaybar command: %s",
18 config->current_bar->swaybar_command); 17 config->current_bar->swaybar_command);
19 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 18 return cmd_results_new(CMD_SUCCESS, NULL);
20} 19}
diff --git a/sway/commands/bar/tray_bindsym.c b/sway/commands/bar/tray_bindsym.c
index ad413446..4e57e35e 100644
--- a/sway/commands/bar/tray_bindsym.c
+++ b/sway/commands/bar/tray_bindsym.c
@@ -12,7 +12,7 @@ struct cmd_results *bar_cmd_tray_bindsym(int argc, char **argv) {
12 } 12 }
13 13
14 if (!config->current_bar) { 14 if (!config->current_bar) {
15 return cmd_results_new(CMD_FAILURE, "tray_bindsym", "No bar defined."); 15 return cmd_results_new(CMD_FAILURE, "No bar defined.");
16 } 16 }
17 17
18 int button = 0; 18 int button = 0;
@@ -21,7 +21,7 @@ struct cmd_results *bar_cmd_tray_bindsym(int argc, char **argv) {
21 button = argv[0][strlen("button")] - '0'; 21 button = argv[0][strlen("button")] - '0';
22 } 22 }
23 if (button < 1 || button > 9) { 23 if (button < 1 || button > 9) {
24 return cmd_results_new(CMD_FAILURE, "tray_bindsym", 24 return cmd_results_new(CMD_FAILURE,
25 "[Bar %s] Only buttons 1 to 9 are supported", 25 "[Bar %s] Only buttons 1 to 9 are supported",
26 config->current_bar->id); 26 config->current_bar->id);
27 } 27 }
@@ -42,14 +42,14 @@ struct cmd_results *bar_cmd_tray_bindsym(int argc, char **argv) {
42 wlr_log(WLR_DEBUG, "[Bar %s] Binding button %d to %s", 42 wlr_log(WLR_DEBUG, "[Bar %s] Binding button %d to %s",
43 config->current_bar->id, button, commands[i]); 43 config->current_bar->id, button, commands[i]);
44 config->current_bar->tray_bindings[button] = commands[i]; 44 config->current_bar->tray_bindings[button] = commands[i];
45 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 45 return cmd_results_new(CMD_SUCCESS, NULL);
46 } 46 }
47 } 47 }
48 48
49 return cmd_results_new(CMD_INVALID, "tray_bindsym", 49 return cmd_results_new(CMD_INVALID,
50 "[Bar %s] Invalid command %s", config->current_bar->id, argv[1]); 50 "[Bar %s] Invalid command %s", config->current_bar->id, argv[1]);
51#else 51#else
52 return cmd_results_new(CMD_INVALID, "tray_bindsym", 52 return cmd_results_new(CMD_INVALID,
53 "Sway has been compiled without tray support"); 53 "Sway has been compiled without tray support");
54#endif 54#endif
55} 55}
diff --git a/sway/commands/bar/tray_output.c b/sway/commands/bar/tray_output.c
index a1169c20..d45c09c6 100644
--- a/sway/commands/bar/tray_output.c
+++ b/sway/commands/bar/tray_output.c
@@ -14,7 +14,7 @@ struct cmd_results *bar_cmd_tray_output(int argc, char **argv) {
14 } 14 }
15 15
16 if (!config->current_bar) { 16 if (!config->current_bar) {
17 return cmd_results_new(CMD_FAILURE, "tray_output", "No bar defined."); 17 return cmd_results_new(CMD_FAILURE, "No bar defined.");
18 } 18 }
19 19
20 list_t *outputs = config->current_bar->tray_outputs; 20 list_t *outputs = config->current_bar->tray_outputs;
@@ -34,9 +34,9 @@ struct cmd_results *bar_cmd_tray_output(int argc, char **argv) {
34 } 34 }
35 list_add(outputs, strdup(argv[0])); 35 list_add(outputs, strdup(argv[0]));
36 36
37 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 37 return cmd_results_new(CMD_SUCCESS, NULL);
38#else 38#else
39 return cmd_results_new(CMD_INVALID, "tray_output", 39 return cmd_results_new(CMD_INVALID,
40 "Sway has been compiled without tray support"); 40 "Sway has been compiled without tray support");
41#endif 41#endif
42} 42}
diff --git a/sway/commands/bar/tray_padding.c b/sway/commands/bar/tray_padding.c
index eb795b00..1e8b294b 100644
--- a/sway/commands/bar/tray_padding.c
+++ b/sway/commands/bar/tray_padding.c
@@ -16,27 +16,27 @@ struct cmd_results *bar_cmd_tray_padding(int argc, char **argv) {
16 } 16 }
17 17
18 if (!config->current_bar) { 18 if (!config->current_bar) {
19 return cmd_results_new(CMD_FAILURE, "tray_padding", "No bar defined."); 19 return cmd_results_new(CMD_FAILURE, "No bar defined.");
20 } 20 }
21 struct bar_config *bar = config->current_bar; 21 struct bar_config *bar = config->current_bar;
22 22
23 char *end; 23 char *end;
24 int padding = strtol(argv[0], &end, 10); 24 int padding = strtol(argv[0], &end, 10);
25 if (padding < 0 || (*end != '\0' && strcasecmp(end, "px") != 0)) { 25 if (padding < 0 || (*end != '\0' && strcasecmp(end, "px") != 0)) {
26 return cmd_results_new(CMD_INVALID, "tray_padding", 26 return cmd_results_new(CMD_INVALID,
27 "[Bar %s] Invalid tray padding value: %s", bar->id, argv[0]); 27 "[Bar %s] Invalid tray padding value: %s", bar->id, argv[0]);
28 } 28 }
29 29
30 if (argc == 2 && strcasecmp(argv[1], "px") != 0) { 30 if (argc == 2 && strcasecmp(argv[1], "px") != 0) {
31 return cmd_results_new(CMD_INVALID, "tray_padding", 31 return cmd_results_new(CMD_INVALID,
32 "Expected 'tray_padding <px> [px]'"); 32 "Expected 'tray_padding <px> [px]'");
33 } 33 }
34 34
35 wlr_log(WLR_DEBUG, "[Bar %s] Setting tray padding to %d", bar->id, padding); 35 wlr_log(WLR_DEBUG, "[Bar %s] Setting tray padding to %d", bar->id, padding);
36 config->current_bar->tray_padding = padding; 36 config->current_bar->tray_padding = padding;
37 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 37 return cmd_results_new(CMD_SUCCESS, NULL);
38#else 38#else
39 return cmd_results_new(CMD_INVALID, "tray_padding", 39 return cmd_results_new(CMD_INVALID,
40 "Sway has been compiled without tray support"); 40 "Sway has been compiled without tray support");
41#endif 41#endif
42} 42}
diff --git a/sway/commands/bar/workspace_buttons.c b/sway/commands/bar/workspace_buttons.c
index cd001e20..773e6357 100644
--- a/sway/commands/bar/workspace_buttons.c
+++ b/sway/commands/bar/workspace_buttons.c
@@ -10,8 +10,7 @@ struct cmd_results *bar_cmd_workspace_buttons(int argc, char **argv) {
10 return error; 10 return error;
11 } 11 }
12 if (!config->current_bar) { 12 if (!config->current_bar) {
13 return cmd_results_new(CMD_FAILURE, 13 return cmd_results_new(CMD_FAILURE, "No bar defined.");
14 "workspace_buttons", "No bar defined.");
15 } 14 }
16 config->current_bar->workspace_buttons = 15 config->current_bar->workspace_buttons =
17 parse_boolean(argv[0], config->current_bar->workspace_buttons); 16 parse_boolean(argv[0], config->current_bar->workspace_buttons);
@@ -22,5 +21,5 @@ struct cmd_results *bar_cmd_workspace_buttons(int argc, char **argv) {
22 wlr_log(WLR_DEBUG, "Disabling workspace buttons on bar: %s", 21 wlr_log(WLR_DEBUG, "Disabling workspace buttons on bar: %s",
23 config->current_bar->id); 22 config->current_bar->id);
24 } 23 }
25 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 24 return cmd_results_new(CMD_SUCCESS, NULL);
26} 25}
diff --git a/sway/commands/bar/wrap_scroll.c b/sway/commands/bar/wrap_scroll.c
index 04a4e6b8..2f7bb090 100644
--- a/sway/commands/bar/wrap_scroll.c
+++ b/sway/commands/bar/wrap_scroll.c
@@ -10,7 +10,7 @@ struct cmd_results *bar_cmd_wrap_scroll(int argc, char **argv) {
10 return error; 10 return error;
11 } 11 }
12 if (!config->current_bar) { 12 if (!config->current_bar) {
13 return cmd_results_new(CMD_FAILURE, "wrap_scroll", "No bar defined."); 13 return cmd_results_new(CMD_FAILURE, "No bar defined.");
14 } 14 }
15 config->current_bar->wrap_scroll = 15 config->current_bar->wrap_scroll =
16 parse_boolean(argv[0], config->current_bar->wrap_scroll); 16 parse_boolean(argv[0], config->current_bar->wrap_scroll);
@@ -21,5 +21,5 @@ struct cmd_results *bar_cmd_wrap_scroll(int argc, char **argv) {
21 wlr_log(WLR_DEBUG, "Disabling wrap scroll on bar: %s", 21 wlr_log(WLR_DEBUG, "Disabling wrap scroll on bar: %s",
22 config->current_bar->id); 22 config->current_bar->id);
23 } 23 }
24 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 24 return cmd_results_new(CMD_SUCCESS, NULL);
25} 25}
diff --git a/sway/commands/bind.c b/sway/commands/bind.c
index be47d412..b0493f7e 100644
--- a/sway/commands/bind.c
+++ b/sway/commands/bind.c
@@ -92,11 +92,11 @@ static struct cmd_results *identify_key(const char* name, bool first_key,
92 if (!button) { 92 if (!button) {
93 if (message) { 93 if (message) {
94 struct cmd_results *error = 94 struct cmd_results *error =
95 cmd_results_new(CMD_INVALID, "bindcode", message); 95 cmd_results_new(CMD_INVALID, message);
96 free(message); 96 free(message);
97 return error; 97 return error;
98 } else { 98 } else {
99 return cmd_results_new(CMD_INVALID, "bindcode", 99 return cmd_results_new(CMD_INVALID,
100 "Unknown button code %s", name); 100 "Unknown button code %s", name);
101 } 101 }
102 } 102 }
@@ -108,12 +108,11 @@ static struct cmd_results *identify_key(const char* name, bool first_key,
108 if (!button) { 108 if (!button) {
109 if (message) { 109 if (message) {
110 struct cmd_results *error = 110 struct cmd_results *error =
111 cmd_results_new(CMD_INVALID, "bindsym", message); 111 cmd_results_new(CMD_INVALID, message);
112 free(message); 112 free(message);
113 return error; 113 return error;
114 } else if (!button) { 114 } else if (!button) {
115 return cmd_results_new(CMD_INVALID, "bindsym", 115 return cmd_results_new(CMD_INVALID, "Unknown button %s", name);
116 "Unknown button %s", name);
117 } 116 }
118 } 117 }
119 *key_val = button; 118 *key_val = button;
@@ -133,10 +132,10 @@ static struct cmd_results *identify_key(const char* name, bool first_key,
133 xkb_keycode_t keycode = strtol(name, NULL, 10); 132 xkb_keycode_t keycode = strtol(name, NULL, 10);
134 if (!xkb_keycode_is_legal_ext(keycode)) { 133 if (!xkb_keycode_is_legal_ext(keycode)) {
135 if (first_key) { 134 if (first_key) {
136 return cmd_results_new(CMD_INVALID, "bindcode", 135 return cmd_results_new(CMD_INVALID,
137 "Invalid keycode or button code '%s'", name); 136 "Invalid keycode or button code '%s'", name);
138 } else { 137 } else {
139 return cmd_results_new(CMD_INVALID, "bindcode", 138 return cmd_results_new(CMD_INVALID,
140 "Invalid keycode '%s'", name); 139 "Invalid keycode '%s'", name);
141 } 140 }
142 } 141 }
@@ -148,7 +147,7 @@ static struct cmd_results *identify_key(const char* name, bool first_key,
148 uint32_t button = get_mouse_bindsym(name, &message); 147 uint32_t button = get_mouse_bindsym(name, &message);
149 if (message) { 148 if (message) {
150 struct cmd_results *error = 149 struct cmd_results *error =
151 cmd_results_new(CMD_INVALID, "bindsym", message); 150 cmd_results_new(CMD_INVALID, message);
152 free(message); 151 free(message);
153 return error; 152 return error;
154 } else if (button) { 153 } else if (button) {
@@ -162,11 +161,10 @@ static struct cmd_results *identify_key(const char* name, bool first_key,
162 XKB_KEYSYM_CASE_INSENSITIVE); 161 XKB_KEYSYM_CASE_INSENSITIVE);
163 if (!keysym) { 162 if (!keysym) {
164 if (first_key) { 163 if (first_key) {
165 return cmd_results_new(CMD_INVALID, "bindsym", 164 return cmd_results_new(CMD_INVALID,
166 "Unknown key or button '%s'", name); 165 "Unknown key or button '%s'", name);
167 } else { 166 } else {
168 return cmd_results_new(CMD_INVALID, "bindsym", 167 return cmd_results_new(CMD_INVALID, "Unknown key '%s'", name);
169 "Unknown key '%s'", name);
170 } 168 }
171 } 169 }
172 *key_val = keysym; 170 *key_val = keysym;
@@ -185,8 +183,7 @@ static struct cmd_results *cmd_bindsym_or_bindcode(int argc, char **argv,
185 183
186 struct sway_binding *binding = calloc(1, sizeof(struct sway_binding)); 184 struct sway_binding *binding = calloc(1, sizeof(struct sway_binding));
187 if (!binding) { 185 if (!binding) {
188 return cmd_results_new(CMD_FAILURE, bindtype, 186 return cmd_results_new(CMD_FAILURE, "Unable to allocate binding");
189 "Unable to allocate binding");
190 } 187 }
191 binding->input = strdup("*"); 188 binding->input = strdup("*");
192 binding->keys = create_list(); 189 binding->keys = create_list();
@@ -229,7 +226,7 @@ static struct cmd_results *cmd_bindsym_or_bindcode(int argc, char **argv,
229 226
230 if (argc < 2) { 227 if (argc < 2) {
231 free_sway_binding(binding); 228 free_sway_binding(binding);
232 return cmd_results_new(CMD_FAILURE, bindtype, 229 return cmd_results_new(CMD_FAILURE,
233 "Invalid %s command " 230 "Invalid %s command "
234 "(expected at least 2 non-option arguments, got %d)", bindtype, argc); 231 "(expected at least 2 non-option arguments, got %d)", bindtype, argc);
235 } 232 }
@@ -259,7 +256,7 @@ static struct cmd_results *cmd_bindsym_or_bindcode(int argc, char **argv,
259 if (!key) { 256 if (!key) {
260 free_sway_binding(binding); 257 free_sway_binding(binding);
261 list_free_items_and_destroy(split); 258 list_free_items_and_destroy(split);
262 return cmd_results_new(CMD_FAILURE, bindtype, 259 return cmd_results_new(CMD_FAILURE,
263 "Unable to allocate binding key"); 260 "Unable to allocate binding key");
264 } 261 }
265 *key = key_val; 262 *key = key_val;
@@ -315,7 +312,7 @@ static struct cmd_results *cmd_bindsym_or_bindcode(int argc, char **argv,
315 312
316 wlr_log(WLR_DEBUG, "%s - Bound %s to command `%s` for device '%s'", 313 wlr_log(WLR_DEBUG, "%s - Bound %s to command `%s` for device '%s'",
317 bindtype, argv[0], binding->command, binding->input); 314 bindtype, argv[0], binding->command, binding->input);
318 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 315 return cmd_results_new(CMD_SUCCESS, NULL);
319} 316}
320 317
321struct cmd_results *cmd_bindsym(int argc, char **argv) { 318struct cmd_results *cmd_bindsym(int argc, char **argv) {
diff --git a/sway/commands/border.c b/sway/commands/border.c
index d51741d2..6be5b794 100644
--- a/sway/commands/border.c
+++ b/sway/commands/border.c
@@ -64,8 +64,7 @@ struct cmd_results *cmd_border(int argc, char **argv) {
64 64
65 struct sway_container *container = config->handler_context.container; 65 struct sway_container *container = config->handler_context.container;
66 if (!container || !container->view) { 66 if (!container || !container->view) {
67 return cmd_results_new(CMD_INVALID, "border", 67 return cmd_results_new(CMD_INVALID, "Only views can have borders");
68 "Only views can have borders");
69 } 68 }
70 struct sway_view *view = container->view; 69 struct sway_view *view = container->view;
71 70
@@ -77,14 +76,14 @@ struct cmd_results *cmd_border(int argc, char **argv) {
77 set_border(container, B_PIXEL); 76 set_border(container, B_PIXEL);
78 } else if (strcmp(argv[0], "csd") == 0) { 77 } else if (strcmp(argv[0], "csd") == 0) {
79 if (!view || !view->xdg_decoration) { 78 if (!view || !view->xdg_decoration) {
80 return cmd_results_new(CMD_INVALID, "border", 79 return cmd_results_new(CMD_INVALID,
81 "This window doesn't support client side decorations"); 80 "This window doesn't support client side decorations");
82 } 81 }
83 set_border(container, B_CSD); 82 set_border(container, B_CSD);
84 } else if (strcmp(argv[0], "toggle") == 0) { 83 } else if (strcmp(argv[0], "toggle") == 0) {
85 border_toggle(container); 84 border_toggle(container);
86 } else { 85 } else {
87 return cmd_results_new(CMD_INVALID, "border", 86 return cmd_results_new(CMD_INVALID,
88 "Expected 'border <none|normal|pixel|csd|toggle>' " 87 "Expected 'border <none|normal|pixel|csd|toggle>' "
89 "or 'border pixel <px>'"); 88 "or 'border pixel <px>'");
90 } 89 }
@@ -98,5 +97,5 @@ struct cmd_results *cmd_border(int argc, char **argv) {
98 97
99 arrange_container(container); 98 arrange_container(container);
100 99
101 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 100 return cmd_results_new(CMD_SUCCESS, NULL);
102} 101}
diff --git a/sway/commands/client.c b/sway/commands/client.c
index 746e8713..10bfa519 100644
--- a/sway/commands/client.c
+++ b/sway/commands/client.c
@@ -61,27 +61,27 @@ static struct cmd_results *handle_command(int argc, char **argv,
61 } 61 }
62 62
63 if (!parse_color_float(argv[0], class->border)) { 63 if (!parse_color_float(argv[0], class->border)) {
64 return cmd_results_new(CMD_INVALID, cmd_name, 64 return cmd_results_new(CMD_INVALID,
65 "Unable to parse border color '%s'", argv[0]); 65 "Unable to parse border color '%s'", argv[0]);
66 } 66 }
67 67
68 if (!parse_color_float(argv[1], class->background)) { 68 if (!parse_color_float(argv[1], class->background)) {
69 return cmd_results_new(CMD_INVALID, cmd_name, 69 return cmd_results_new(CMD_INVALID,
70 "Unable to parse background color '%s'", argv[1]); 70 "Unable to parse background color '%s'", argv[1]);
71 } 71 }
72 72
73 if (!parse_color_float(argv[2], class->text)) { 73 if (!parse_color_float(argv[2], class->text)) {
74 return cmd_results_new(CMD_INVALID, cmd_name, 74 return cmd_results_new(CMD_INVALID,
75 "Unable to parse text color '%s'", argv[2]); 75 "Unable to parse text color '%s'", argv[2]);
76 } 76 }
77 77
78 if (!parse_color_float(argv[3], class->indicator)) { 78 if (!parse_color_float(argv[3], class->indicator)) {
79 return cmd_results_new(CMD_INVALID, cmd_name, 79 return cmd_results_new(CMD_INVALID,
80 "Unable to parse indicator color '%s'", argv[3]); 80 "Unable to parse indicator color '%s'", argv[3]);
81 } 81 }
82 82
83 if (!parse_color_float(argv[4], class->child_border)) { 83 if (!parse_color_float(argv[4], class->child_border)) {
84 return cmd_results_new(CMD_INVALID, cmd_name, 84 return cmd_results_new(CMD_INVALID,
85 "Unable to parse child border color '%s'", argv[4]); 85 "Unable to parse child border color '%s'", argv[4]);
86 } 86 }
87 87
@@ -94,7 +94,7 @@ static struct cmd_results *handle_command(int argc, char **argv,
94 } 94 }
95 } 95 }
96 96
97 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 97 return cmd_results_new(CMD_SUCCESS, NULL);
98} 98}
99 99
100struct cmd_results *cmd_client_focused(int argc, char **argv) { 100struct cmd_results *cmd_client_focused(int argc, char **argv) {
@@ -115,5 +115,5 @@ struct cmd_results *cmd_client_urgent(int argc, char **argv) {
115 115
116struct cmd_results *cmd_client_noop(int argc, char **argv) { 116struct cmd_results *cmd_client_noop(int argc, char **argv) {
117 wlr_log(WLR_INFO, "Warning: %s is ignored by sway", argv[-1]); 117 wlr_log(WLR_INFO, "Warning: %s is ignored by sway", argv[-1]);
118 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 118 return cmd_results_new(CMD_SUCCESS, NULL);
119} 119}
diff --git a/sway/commands/create_output.c b/sway/commands/create_output.c
index 3f870acb..9961c8fb 100644
--- a/sway/commands/create_output.c
+++ b/sway/commands/create_output.c
@@ -37,9 +37,9 @@ struct cmd_results *cmd_create_output(int argc, char **argv) {
37 wlr_multi_for_each_backend(server.backend, create_output, &done); 37 wlr_multi_for_each_backend(server.backend, create_output, &done);
38 38
39 if (!done) { 39 if (!done) {
40 return cmd_results_new(CMD_INVALID, "create_output", 40 return cmd_results_new(CMD_INVALID,
41 "Can only create outputs for Wayland or X11 backends"); 41 "Can only create outputs for Wayland or X11 backends");
42 } 42 }
43 43
44 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 44 return cmd_results_new(CMD_SUCCESS, NULL);
45} 45}
diff --git a/sway/commands/default_border.c b/sway/commands/default_border.c
index 2e356d3d..5c0fee3f 100644
--- a/sway/commands/default_border.c
+++ b/sway/commands/default_border.c
@@ -16,12 +16,12 @@ struct cmd_results *cmd_default_border(int argc, char **argv) {
16 } else if (strcmp(argv[0], "pixel") == 0) { 16 } else if (strcmp(argv[0], "pixel") == 0) {
17 config->border = B_PIXEL; 17 config->border = B_PIXEL;
18 } else { 18 } else {
19 return cmd_results_new(CMD_INVALID, "default_border", 19 return cmd_results_new(CMD_INVALID,
20 "Expected 'default_border <none|normal|pixel>' or 'default_border <normal|pixel> <px>'"); 20 "Expected 'default_border <none|normal|pixel>' or 'default_border <normal|pixel> <px>'");
21 } 21 }
22 if (argc == 2) { 22 if (argc == 2) {
23 config->border_thickness = atoi(argv[1]); 23 config->border_thickness = atoi(argv[1]);
24 } 24 }
25 25
26 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 26 return cmd_results_new(CMD_SUCCESS, NULL);
27} 27}
diff --git a/sway/commands/default_floating_border.c b/sway/commands/default_floating_border.c
index 1bfc24af..7e4edc36 100644
--- a/sway/commands/default_floating_border.c
+++ b/sway/commands/default_floating_border.c
@@ -17,7 +17,7 @@ struct cmd_results *cmd_default_floating_border(int argc, char **argv) {
17 } else if (strcmp(argv[0], "pixel") == 0) { 17 } else if (strcmp(argv[0], "pixel") == 0) {
18 config->floating_border = B_PIXEL; 18 config->floating_border = B_PIXEL;
19 } else { 19 } else {
20 return cmd_results_new(CMD_INVALID, "default_floating_border", 20 return cmd_results_new(CMD_INVALID,
21 "Expected 'default_floating_border <none|normal|pixel>' " 21 "Expected 'default_floating_border <none|normal|pixel>' "
22 "or 'default_floating_border <normal|pixel> <px>'"); 22 "or 'default_floating_border <normal|pixel> <px>'");
23 } 23 }
@@ -25,5 +25,5 @@ struct cmd_results *cmd_default_floating_border(int argc, char **argv) {
25 config->floating_border_thickness = atoi(argv[1]); 25 config->floating_border_thickness = atoi(argv[1]);
26 } 26 }
27 27
28 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 28 return cmd_results_new(CMD_SUCCESS, NULL);
29} 29}
diff --git a/sway/commands/default_orientation.c b/sway/commands/default_orientation.c
index a5347ce2..fd42c167 100644
--- a/sway/commands/default_orientation.c
+++ b/sway/commands/default_orientation.c
@@ -14,8 +14,8 @@ struct cmd_results *cmd_default_orientation(int argc, char **argv) {
14 } else if (strcasecmp(argv[0], "auto") == 0) { 14 } else if (strcasecmp(argv[0], "auto") == 0) {
15 // Do nothing 15 // Do nothing
16 } else { 16 } else {
17 return cmd_results_new(CMD_INVALID, "default_orientation", 17 return cmd_results_new(CMD_INVALID,
18 "Expected 'orientation <horizontal|vertical|auto>'"); 18 "Expected 'orientation <horizontal|vertical|auto>'");
19 } 19 }
20 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 20 return cmd_results_new(CMD_SUCCESS, NULL);
21} 21}
diff --git a/sway/commands/exec.c b/sway/commands/exec.c
index 7fc54123..dc8d8aac 100644
--- a/sway/commands/exec.c
+++ b/sway/commands/exec.c
@@ -5,12 +5,12 @@
5#include "stringop.h" 5#include "stringop.h"
6 6
7struct cmd_results *cmd_exec(int argc, char **argv) { 7struct cmd_results *cmd_exec(int argc, char **argv) {
8 if (!config->active) return cmd_results_new(CMD_DEFER, "exec", NULL); 8 if (!config->active) return cmd_results_new(CMD_DEFER, NULL);
9 if (config->reloading) { 9 if (config->reloading) {
10 char *args = join_args(argv, argc); 10 char *args = join_args(argv, argc);
11 wlr_log(WLR_DEBUG, "Ignoring 'exec %s' due to reload", args); 11 wlr_log(WLR_DEBUG, "Ignoring 'exec %s' due to reload", args);
12 free(args); 12 free(args);
13 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 13 return cmd_results_new(CMD_SUCCESS, NULL);
14 } 14 }
15 return cmd_exec_always(argc, argv); 15 return cmd_exec_always(argc, argv);
16} 16}
diff --git a/sway/commands/exec_always.c b/sway/commands/exec_always.c
index 9ec28d81..1ed6c7e6 100644
--- a/sway/commands/exec_always.c
+++ b/sway/commands/exec_always.c
@@ -15,7 +15,9 @@
15 15
16struct cmd_results *cmd_exec_always(int argc, char **argv) { 16struct cmd_results *cmd_exec_always(int argc, char **argv) {
17 struct cmd_results *error = NULL; 17 struct cmd_results *error = NULL;
18 if (!config->active || config->validating) return cmd_results_new(CMD_DEFER, NULL, NULL); 18 if (!config->active || config->validating) {
19 return cmd_results_new(CMD_DEFER, NULL);
20 }
19 if ((error = checkarg(argc, argv[-1], EXPECTED_AT_LEAST, 1))) { 21 if ((error = checkarg(argc, argv[-1], EXPECTED_AT_LEAST, 1))) {
20 return error; 22 return error;
21 } 23 }
@@ -71,7 +73,7 @@ struct cmd_results *cmd_exec_always(int argc, char **argv) {
71 } else if (pid < 0) { 73 } else if (pid < 0) {
72 close(fd[0]); 74 close(fd[0]);
73 close(fd[1]); 75 close(fd[1]);
74 return cmd_results_new(CMD_FAILURE, argv[-1], "fork() failed"); 76 return cmd_results_new(CMD_FAILURE, "fork() failed");
75 } 77 }
76 close(fd[1]); // close write 78 close(fd[1]); // close write
77 ssize_t s = 0; 79 ssize_t s = 0;
@@ -85,9 +87,8 @@ struct cmd_results *cmd_exec_always(int argc, char **argv) {
85 wlr_log(WLR_DEBUG, "Child process created with pid %d", child); 87 wlr_log(WLR_DEBUG, "Child process created with pid %d", child);
86 root_record_workspace_pid(child); 88 root_record_workspace_pid(child);
87 } else { 89 } else {
88 return cmd_results_new(CMD_FAILURE, argv[-1], 90 return cmd_results_new(CMD_FAILURE, "Second fork() failed");
89 "Second fork() failed");
90 } 91 }
91 92
92 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 93 return cmd_results_new(CMD_SUCCESS, NULL);
93} 94}
diff --git a/sway/commands/exit.c b/sway/commands/exit.c
index d5353c20..10cde640 100644
--- a/sway/commands/exit.c
+++ b/sway/commands/exit.c
@@ -10,5 +10,5 @@ struct cmd_results *cmd_exit(int argc, char **argv) {
10 return error; 10 return error;
11 } 11 }
12 sway_terminate(0); 12 sway_terminate(0);
13 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 13 return cmd_results_new(CMD_SUCCESS, NULL);
14} 14}
diff --git a/sway/commands/floating.c b/sway/commands/floating.c
index 4b82921c..e95f3185 100644
--- a/sway/commands/floating.c
+++ b/sway/commands/floating.c
@@ -17,14 +17,13 @@ struct cmd_results *cmd_floating(int argc, char **argv) {
17 return error; 17 return error;
18 } 18 }
19 if (!root->outputs->length) { 19 if (!root->outputs->length) {
20 return cmd_results_new(CMD_INVALID, "floating", 20 return cmd_results_new(CMD_INVALID,
21 "Can't run this command while there's no outputs connected."); 21 "Can't run this command while there's no outputs connected.");
22 } 22 }
23 struct sway_container *container = config->handler_context.container; 23 struct sway_container *container = config->handler_context.container;
24 struct sway_workspace *workspace = config->handler_context.workspace; 24 struct sway_workspace *workspace = config->handler_context.workspace;
25 if (!container && workspace->tiling->length == 0) { 25 if (!container && workspace->tiling->length == 0) {
26 return cmd_results_new(CMD_INVALID, "floating", 26 return cmd_results_new(CMD_INVALID, "Can't float an empty workspace");
27 "Can't float an empty workspace");
28 } 27 }
29 if (!container) { 28 if (!container) {
30 // Wrap the workspace's children in a container so we can float it 29 // Wrap the workspace's children in a container so we can float it
@@ -48,5 +47,5 @@ struct cmd_results *cmd_floating(int argc, char **argv) {
48 47
49 arrange_workspace(container->workspace); 48 arrange_workspace(container->workspace);
50 49
51 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 50 return cmd_results_new(CMD_SUCCESS, NULL);
52} 51}
diff --git a/sway/commands/floating_minmax_size.c b/sway/commands/floating_minmax_size.c
index 0af78908..31c1e999 100644
--- a/sway/commands/floating_minmax_size.c
+++ b/sway/commands/floating_minmax_size.c
@@ -8,10 +8,10 @@
8#include "sway/commands.h" 8#include "sway/commands.h"
9#include "log.h" 9#include "log.h"
10 10
11static const char* min_usage = 11static const char min_usage[] =
12 "Expected 'floating_minimum_size <width> x <height>'"; 12 "Expected 'floating_minimum_size <width> x <height>'";
13 13
14static const char* max_usage = 14static const char max_usage[] =
15 "Expected 'floating_maximum_size <width> x <height>'"; 15 "Expected 'floating_maximum_size <width> x <height>'";
16 16
17static struct cmd_results *handle_command(int argc, char **argv, char *cmd_name, 17static struct cmd_results *handle_command(int argc, char **argv, char *cmd_name,
@@ -39,7 +39,7 @@ static struct cmd_results *handle_command(int argc, char **argv, char *cmd_name,
39 *config_width = width; 39 *config_width = width;
40 *config_height = height; 40 *config_height = height;
41 41
42 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 42 return cmd_results_new(CMD_SUCCESS, NULL);
43} 43}
44 44
45struct cmd_results *cmd_floating_minimum_size(int argc, char **argv) { 45struct cmd_results *cmd_floating_minimum_size(int argc, char **argv) {
diff --git a/sway/commands/floating_modifier.c b/sway/commands/floating_modifier.c
index f5d2b3fe..3674971a 100644
--- a/sway/commands/floating_modifier.c
+++ b/sway/commands/floating_modifier.c
@@ -11,8 +11,7 @@ struct cmd_results *cmd_floating_modifier(int argc, char **argv) {
11 11
12 uint32_t mod = get_modifier_mask_by_name(argv[0]); 12 uint32_t mod = get_modifier_mask_by_name(argv[0]);
13 if (!mod) { 13 if (!mod) {
14 return cmd_results_new(CMD_INVALID, "floating_modifier", 14 return cmd_results_new(CMD_INVALID, "Invalid modifier");
15 "Invalid modifier");
16 } 15 }
17 16
18 if (argc == 1 || strcasecmp(argv[1], "normal") == 0) { 17 if (argc == 1 || strcasecmp(argv[1], "normal") == 0) {
@@ -20,11 +19,11 @@ struct cmd_results *cmd_floating_modifier(int argc, char **argv) {
20 } else if (strcasecmp(argv[1], "inverse") == 0) { 19 } else if (strcasecmp(argv[1], "inverse") == 0) {
21 config->floating_mod_inverse = true; 20 config->floating_mod_inverse = true;
22 } else { 21 } else {
23 return cmd_results_new(CMD_INVALID, "floating_modifier", 22 return cmd_results_new(CMD_INVALID,
24 "Usage: floating_modifier <mod> [inverse|normal]"); 23 "Usage: floating_modifier <mod> [inverse|normal]");
25 } 24 }
26 25
27 config->floating_mod = mod; 26 config->floating_mod = mod;
28 27
29 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 28 return cmd_results_new(CMD_SUCCESS, NULL);
30} 29}
diff --git a/sway/commands/focus.c b/sway/commands/focus.c
index 97ffe91c..8564f3ff 100644
--- a/sway/commands/focus.c
+++ b/sway/commands/focus.c
@@ -179,17 +179,17 @@ static struct cmd_results *focus_mode(struct sway_workspace *ws,
179 seat_set_focus_container(seat, new_focus); 179 seat_set_focus_container(seat, new_focus);
180 seat_consider_warp_to_focus(seat); 180 seat_consider_warp_to_focus(seat);
181 } else { 181 } else {
182 return cmd_results_new(CMD_FAILURE, "focus", 182 return cmd_results_new(CMD_FAILURE,
183 "Failed to find a %s container in workspace", 183 "Failed to find a %s container in workspace",
184 floating ? "floating" : "tiling"); 184 floating ? "floating" : "tiling");
185 } 185 }
186 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 186 return cmd_results_new(CMD_SUCCESS, NULL);
187} 187}
188 188
189static struct cmd_results *focus_output(struct sway_seat *seat, 189static struct cmd_results *focus_output(struct sway_seat *seat,
190 int argc, char **argv) { 190 int argc, char **argv) {
191 if (!argc) { 191 if (!argc) {
192 return cmd_results_new(CMD_INVALID, "focus", 192 return cmd_results_new(CMD_INVALID,
193 "Expected 'focus output <direction|name>'"); 193 "Expected 'focus output <direction|name>'");
194 } 194 }
195 char *identifier = join_args(argv, argc); 195 char *identifier = join_args(argv, argc);
@@ -199,7 +199,7 @@ static struct cmd_results *focus_output(struct sway_seat *seat,
199 enum wlr_direction direction; 199 enum wlr_direction direction;
200 if (!parse_direction(identifier, &direction)) { 200 if (!parse_direction(identifier, &direction)) {
201 free(identifier); 201 free(identifier);
202 return cmd_results_new(CMD_INVALID, "focus", 202 return cmd_results_new(CMD_INVALID,
203 "There is no output with that name"); 203 "There is no output with that name");
204 } 204 }
205 struct sway_workspace *ws = seat_get_focused_workspace(seat); 205 struct sway_workspace *ws = seat_get_focused_workspace(seat);
@@ -223,21 +223,21 @@ static struct cmd_results *focus_output(struct sway_seat *seat,
223 seat_consider_warp_to_focus(seat); 223 seat_consider_warp_to_focus(seat);
224 } 224 }
225 225
226 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 226 return cmd_results_new(CMD_SUCCESS, NULL);
227} 227}
228 228
229static struct cmd_results *focus_parent(void) { 229static struct cmd_results *focus_parent(void) {
230 struct sway_seat *seat = config->handler_context.seat; 230 struct sway_seat *seat = config->handler_context.seat;
231 struct sway_container *con = config->handler_context.container; 231 struct sway_container *con = config->handler_context.container;
232 if (!con || con->is_fullscreen) { 232 if (!con || con->is_fullscreen) {
233 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 233 return cmd_results_new(CMD_SUCCESS, NULL);
234 } 234 }
235 struct sway_node *parent = node_get_parent(&con->node); 235 struct sway_node *parent = node_get_parent(&con->node);
236 if (parent) { 236 if (parent) {
237 seat_set_focus(seat, parent); 237 seat_set_focus(seat, parent);
238 seat_consider_warp_to_focus(seat); 238 seat_consider_warp_to_focus(seat);
239 } 239 }
240 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 240 return cmd_results_new(CMD_SUCCESS, NULL);
241} 241}
242 242
243static struct cmd_results *focus_child(void) { 243static struct cmd_results *focus_child(void) {
@@ -248,15 +248,15 @@ static struct cmd_results *focus_child(void) {
248 seat_set_focus(seat, focus); 248 seat_set_focus(seat, focus);
249 seat_consider_warp_to_focus(seat); 249 seat_consider_warp_to_focus(seat);
250 } 250 }
251 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 251 return cmd_results_new(CMD_SUCCESS, NULL);
252} 252}
253 253
254struct cmd_results *cmd_focus(int argc, char **argv) { 254struct cmd_results *cmd_focus(int argc, char **argv) {
255 if (config->reading || !config->active) { 255 if (config->reading || !config->active) {
256 return cmd_results_new(CMD_DEFER, NULL, NULL); 256 return cmd_results_new(CMD_DEFER, NULL);
257 } 257 }
258 if (!root->outputs->length) { 258 if (!root->outputs->length) {
259 return cmd_results_new(CMD_INVALID, "focus", 259 return cmd_results_new(CMD_INVALID,
260 "Can't run this command while there's no outputs connected."); 260 "Can't run this command while there's no outputs connected.");
261 } 261 }
262 struct sway_node *node = config->handler_context.node; 262 struct sway_node *node = config->handler_context.node;
@@ -264,7 +264,7 @@ struct cmd_results *cmd_focus(int argc, char **argv) {
264 struct sway_workspace *workspace = config->handler_context.workspace; 264 struct sway_workspace *workspace = config->handler_context.workspace;
265 struct sway_seat *seat = config->handler_context.seat; 265 struct sway_seat *seat = config->handler_context.seat;
266 if (node->type < N_WORKSPACE) { 266 if (node->type < N_WORKSPACE) {
267 return cmd_results_new(CMD_FAILURE, "focus", 267 return cmd_results_new(CMD_FAILURE,
268 "Command 'focus' cannot be used above the workspace level"); 268 "Command 'focus' cannot be used above the workspace level");
269 } 269 }
270 270
@@ -274,7 +274,7 @@ struct cmd_results *cmd_focus(int argc, char **argv) {
274 } 274 }
275 seat_set_focus_container(seat, container); 275 seat_set_focus_container(seat, container);
276 seat_consider_warp_to_focus(seat); 276 seat_consider_warp_to_focus(seat);
277 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 277 return cmd_results_new(CMD_SUCCESS, NULL);
278 } 278 }
279 279
280 if (strcmp(argv[0], "floating") == 0) { 280 if (strcmp(argv[0], "floating") == 0) {
@@ -300,7 +300,7 @@ struct cmd_results *cmd_focus(int argc, char **argv) {
300 300
301 enum wlr_direction direction = 0; 301 enum wlr_direction direction = 0;
302 if (!parse_direction(argv[0], &direction)) { 302 if (!parse_direction(argv[0], &direction)) {
303 return cmd_results_new(CMD_INVALID, "focus", 303 return cmd_results_new(CMD_INVALID,
304 "Expected 'focus <direction|parent|child|mode_toggle|floating|tiling>' " 304 "Expected 'focus <direction|parent|child|mode_toggle|floating|tiling>' "
305 "or 'focus output <direction|name>'"); 305 "or 'focus output <direction|name>'");
306 } 306 }
@@ -310,14 +310,14 @@ struct cmd_results *cmd_focus(int argc, char **argv) {
310 struct sway_output *new_output = 310 struct sway_output *new_output =
311 output_get_in_direction(workspace->output, direction); 311 output_get_in_direction(workspace->output, direction);
312 if (!new_output) { 312 if (!new_output) {
313 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 313 return cmd_results_new(CMD_SUCCESS, NULL);
314 } 314 }
315 315
316 struct sway_node *node = 316 struct sway_node *node =
317 get_node_in_output_direction(new_output, direction); 317 get_node_in_output_direction(new_output, direction);
318 seat_set_focus(seat, node); 318 seat_set_focus(seat, node);
319 seat_consider_warp_to_focus(seat); 319 seat_consider_warp_to_focus(seat);
320 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 320 return cmd_results_new(CMD_SUCCESS, NULL);
321 } 321 }
322 322
323 struct sway_node *next_focus = 323 struct sway_node *next_focus =
@@ -327,5 +327,5 @@ struct cmd_results *cmd_focus(int argc, char **argv) {
327 seat_consider_warp_to_focus(seat); 327 seat_consider_warp_to_focus(seat);
328 } 328 }
329 329
330 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 330 return cmd_results_new(CMD_SUCCESS, NULL);
331} 331}
diff --git a/sway/commands/focus_follows_mouse.c b/sway/commands/focus_follows_mouse.c
index d0d2cb8a..7afb5f62 100644
--- a/sway/commands/focus_follows_mouse.c
+++ b/sway/commands/focus_follows_mouse.c
@@ -14,8 +14,8 @@ struct cmd_results *cmd_focus_follows_mouse(int argc, char **argv) {
14 } else if(strcmp(argv[0], "always") == 0) { 14 } else if(strcmp(argv[0], "always") == 0) {
15 config->focus_follows_mouse = FOLLOWS_ALWAYS; 15 config->focus_follows_mouse = FOLLOWS_ALWAYS;
16 } else { 16 } else {
17 return cmd_results_new(CMD_FAILURE, "focus_follows_mouse", 17 return cmd_results_new(CMD_FAILURE,
18 "Expected 'focus_follows_mouse no|yes|always'"); 18 "Expected 'focus_follows_mouse no|yes|always'");
19 } 19 }
20 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 20 return cmd_results_new(CMD_SUCCESS, NULL);
21} 21}
diff --git a/sway/commands/focus_on_window_activation.c b/sway/commands/focus_on_window_activation.c
index 1fb07918..2163fc59 100644
--- a/sway/commands/focus_on_window_activation.c
+++ b/sway/commands/focus_on_window_activation.c
@@ -16,10 +16,10 @@ struct cmd_results *cmd_focus_on_window_activation(int argc, char **argv) {
16 } else if (strcmp(argv[0], "none") == 0) { 16 } else if (strcmp(argv[0], "none") == 0) {
17 config->focus_on_window_activation = FOWA_NONE; 17 config->focus_on_window_activation = FOWA_NONE;
18 } else { 18 } else {
19 return cmd_results_new(CMD_INVALID, "focus_on_window_activation", 19 return cmd_results_new(CMD_INVALID,
20 "Expected " 20 "Expected "
21 "'focus_on_window_activation smart|urgent|focus|none'"); 21 "'focus_on_window_activation smart|urgent|focus|none'");
22 } 22 }
23 23
24 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 24 return cmd_results_new(CMD_SUCCESS, NULL);
25} 25}
diff --git a/sway/commands/focus_wrapping.c b/sway/commands/focus_wrapping.c
index 562ee4f9..3a74a3ea 100644
--- a/sway/commands/focus_wrapping.c
+++ b/sway/commands/focus_wrapping.c
@@ -17,5 +17,5 @@ struct cmd_results *cmd_focus_wrapping(int argc, char **argv) {
17 config->focus_wrapping = WRAP_NO; 17 config->focus_wrapping = WRAP_NO;
18 } 18 }
19 19
20 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 20 return cmd_results_new(CMD_SUCCESS, NULL);
21} 21}
diff --git a/sway/commands/font.c b/sway/commands/font.c
index 3071ccd8..c54365b5 100644
--- a/sway/commands/font.c
+++ b/sway/commands/font.c
@@ -23,5 +23,5 @@ struct cmd_results *cmd_font(int argc, char **argv) {
23 23
24 free(font); 24 free(font);
25 config_update_font_height(true); 25 config_update_font_height(true);
26 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 26 return cmd_results_new(CMD_SUCCESS, NULL);
27} 27}
diff --git a/sway/commands/for_window.c b/sway/commands/for_window.c
index 7c0f7d7f..f151575e 100644
--- a/sway/commands/for_window.c
+++ b/sway/commands/for_window.c
@@ -14,7 +14,7 @@ struct cmd_results *cmd_for_window(int argc, char **argv) {
14 char *err_str = NULL; 14 char *err_str = NULL;
15 struct criteria *criteria = criteria_parse(argv[0], &err_str); 15 struct criteria *criteria = criteria_parse(argv[0], &err_str);
16 if (!criteria) { 16 if (!criteria) {
17 error = cmd_results_new(CMD_INVALID, "for_window", err_str); 17 error = cmd_results_new(CMD_INVALID, err_str);
18 free(err_str); 18 free(err_str);
19 return error; 19 return error;
20 } 20 }
@@ -25,5 +25,5 @@ struct cmd_results *cmd_for_window(int argc, char **argv) {
25 list_add(config->criteria, criteria); 25 list_add(config->criteria, criteria);
26 wlr_log(WLR_DEBUG, "for_window: '%s' -> '%s' added", criteria->raw, criteria->cmdlist); 26 wlr_log(WLR_DEBUG, "for_window: '%s' -> '%s' added", criteria->raw, criteria->cmdlist);
27 27
28 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 28 return cmd_results_new(CMD_SUCCESS, NULL);
29} 29}
diff --git a/sway/commands/force_display_urgency_hint.c b/sway/commands/force_display_urgency_hint.c
index 5e5e2d55..3202fc43 100644
--- a/sway/commands/force_display_urgency_hint.c
+++ b/sway/commands/force_display_urgency_hint.c
@@ -12,12 +12,12 @@ struct cmd_results *cmd_force_display_urgency_hint(int argc, char **argv) {
12 int timeout = (int)strtol(argv[0], &err, 10); 12 int timeout = (int)strtol(argv[0], &err, 10);
13 if (*err) { 13 if (*err) {
14 if (strcmp(err, "ms") != 0) { 14 if (strcmp(err, "ms") != 0) {
15 return cmd_results_new(CMD_INVALID, "force_display_urgency_hint", 15 return cmd_results_new(CMD_INVALID,
16 "Expected 'force_display_urgency_hint <timeout> ms'"); 16 "Expected 'force_display_urgency_hint <timeout> ms'");
17 } 17 }
18 } 18 }
19 19
20 config->urgent_timeout = timeout > 0 ? timeout : 0; 20 config->urgent_timeout = timeout > 0 ? timeout : 0;
21 21
22 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 22 return cmd_results_new(CMD_SUCCESS, NULL);
23} 23}
diff --git a/sway/commands/force_focus_wrapping.c b/sway/commands/force_focus_wrapping.c
index 0892d9e9..e646ae9b 100644
--- a/sway/commands/force_focus_wrapping.c
+++ b/sway/commands/force_focus_wrapping.c
@@ -16,5 +16,5 @@ struct cmd_results *cmd_force_focus_wrapping(int argc, char **argv) {
16 config->focus_wrapping = WRAP_YES; 16 config->focus_wrapping = WRAP_YES;
17 } 17 }
18 18
19 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 19 return cmd_results_new(CMD_SUCCESS, NULL);
20} 20}
diff --git a/sway/commands/fullscreen.c b/sway/commands/fullscreen.c
index b78187d9..920b9bd0 100644
--- a/sway/commands/fullscreen.c
+++ b/sway/commands/fullscreen.c
@@ -13,14 +13,14 @@ struct cmd_results *cmd_fullscreen(int argc, char **argv) {
13 return error; 13 return error;
14 } 14 }
15 if (!root->outputs->length) { 15 if (!root->outputs->length) {
16 return cmd_results_new(CMD_FAILURE, "fullscreen", 16 return cmd_results_new(CMD_FAILURE,
17 "Can't run this command while there's no outputs connected."); 17 "Can't run this command while there's no outputs connected.");
18 } 18 }
19 struct sway_node *node = config->handler_context.node; 19 struct sway_node *node = config->handler_context.node;
20 struct sway_container *container = config->handler_context.container; 20 struct sway_container *container = config->handler_context.container;
21 struct sway_workspace *workspace = config->handler_context.workspace; 21 struct sway_workspace *workspace = config->handler_context.workspace;
22 if (node->type == N_WORKSPACE && workspace->tiling->length == 0) { 22 if (node->type == N_WORKSPACE && workspace->tiling->length == 0) {
23 return cmd_results_new(CMD_FAILURE, "fullscreen", 23 return cmd_results_new(CMD_FAILURE,
24 "Can't fullscreen an empty workspace"); 24 "Can't fullscreen an empty workspace");
25 } 25 }
26 if (node->type == N_WORKSPACE) { 26 if (node->type == N_WORKSPACE) {
@@ -38,5 +38,5 @@ struct cmd_results *cmd_fullscreen(int argc, char **argv) {
38 container_set_fullscreen(container, enable); 38 container_set_fullscreen(container, enable);
39 arrange_workspace(workspace); 39 arrange_workspace(workspace);
40 40
41 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 41 return cmd_results_new(CMD_SUCCESS, NULL);
42} 42}
diff --git a/sway/commands/gaps.c b/sway/commands/gaps.c
index faaeab37..021df843 100644
--- a/sway/commands/gaps.c
+++ b/sway/commands/gaps.c
@@ -43,7 +43,7 @@ static void prevent_invalid_outer_gaps(void) {
43} 43}
44 44
45// gaps inner|outer|horizontal|vertical|top|right|bottom|left <px> 45// gaps inner|outer|horizontal|vertical|top|right|bottom|left <px>
46static const char *expected_defaults = 46static const char expected_defaults[] =
47 "'gaps inner|outer|horizontal|vertical|top|right|bottom|left <px>'"; 47 "'gaps inner|outer|horizontal|vertical|top|right|bottom|left <px>'";
48static struct cmd_results *gaps_set_defaults(int argc, char **argv) { 48static struct cmd_results *gaps_set_defaults(int argc, char **argv) {
49 struct cmd_results *error = checkarg(argc, "gaps", EXPECTED_EQUAL_TO, 2); 49 struct cmd_results *error = checkarg(argc, "gaps", EXPECTED_EQUAL_TO, 2);
@@ -54,8 +54,7 @@ static struct cmd_results *gaps_set_defaults(int argc, char **argv) {
54 char *end; 54 char *end;
55 int amount = strtol(argv[1], &end, 10); 55 int amount = strtol(argv[1], &end, 10);
56 if (strlen(end) && strcasecmp(end, "px") != 0) { 56 if (strlen(end) && strcasecmp(end, "px") != 0) {
57 return cmd_results_new(CMD_INVALID, "gaps", 57 return cmd_results_new(CMD_INVALID, "Expected %s", expected_defaults);
58 "Expected %s", expected_defaults);
59 } 58 }
60 59
61 bool valid = false; 60 bool valid = false;
@@ -85,12 +84,11 @@ static struct cmd_results *gaps_set_defaults(int argc, char **argv) {
85 } 84 }
86 } 85 }
87 if (!valid) { 86 if (!valid) {
88 return cmd_results_new(CMD_INVALID, "gaps", 87 return cmd_results_new(CMD_INVALID, "Expected %s", expected_defaults);
89 "Expected %s", expected_defaults);
90 } 88 }
91 89
92 prevent_invalid_outer_gaps(); 90 prevent_invalid_outer_gaps();
93 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 91 return cmd_results_new(CMD_SUCCESS, NULL);
94} 92}
95 93
96static void apply_gaps_op(int *prop, enum gaps_op op, int amount) { 94static void apply_gaps_op(int *prop, enum gaps_op op, int amount) {
@@ -136,7 +134,7 @@ static void configure_gaps(struct sway_workspace *ws, void *_data) {
136 134
137// gaps inner|outer|horizontal|vertical|top|right|bottom|left current|all 135// gaps inner|outer|horizontal|vertical|top|right|bottom|left current|all
138// set|plus|minus <px> 136// set|plus|minus <px>
139static const char *expected_runtime = "'gaps inner|outer|horizontal|vertical|" 137static const char expected_runtime[] = "'gaps inner|outer|horizontal|vertical|"
140 "top|right|bottom|left current|all set|plus|minus <px>'"; 138 "top|right|bottom|left current|all set|plus|minus <px>'";
141static struct cmd_results *gaps_set_runtime(int argc, char **argv) { 139static struct cmd_results *gaps_set_runtime(int argc, char **argv) {
142 struct cmd_results *error = checkarg(argc, "gaps", EXPECTED_EQUAL_TO, 4); 140 struct cmd_results *error = checkarg(argc, "gaps", EXPECTED_EQUAL_TO, 4);
@@ -144,7 +142,7 @@ static struct cmd_results *gaps_set_runtime(int argc, char **argv) {
144 return error; 142 return error;
145 } 143 }
146 if (!root->outputs->length) { 144 if (!root->outputs->length) {
147 return cmd_results_new(CMD_INVALID, "gaps", 145 return cmd_results_new(CMD_INVALID,
148 "Can't run this command while there's no outputs connected."); 146 "Can't run this command while there's no outputs connected.");
149 } 147 }
150 148
@@ -164,8 +162,7 @@ static struct cmd_results *gaps_set_runtime(int argc, char **argv) {
164 } 162 }
165 if (!data.inner && !data.outer.top && !data.outer.right && 163 if (!data.inner && !data.outer.top && !data.outer.right &&
166 !data.outer.bottom && !data.outer.left) { 164 !data.outer.bottom && !data.outer.left) {
167 return cmd_results_new(CMD_INVALID, "gaps", 165 return cmd_results_new(CMD_INVALID, "Expected %s", expected_runtime);
168 "Expected %s", expected_runtime);
169 } 166 }
170 167
171 bool all; 168 bool all;
@@ -174,8 +171,7 @@ static struct cmd_results *gaps_set_runtime(int argc, char **argv) {
174 } else if (strcasecmp(argv[1], "all") == 0) { 171 } else if (strcasecmp(argv[1], "all") == 0) {
175 all = true; 172 all = true;
176 } else { 173 } else {
177 return cmd_results_new(CMD_INVALID, "gaps", 174 return cmd_results_new(CMD_INVALID, "Expected %s", expected_runtime);
178 "Expected %s", expected_runtime);
179 } 175 }
180 176
181 if (strcasecmp(argv[2], "set") == 0) { 177 if (strcasecmp(argv[2], "set") == 0) {
@@ -185,15 +181,13 @@ static struct cmd_results *gaps_set_runtime(int argc, char **argv) {
185 } else if (strcasecmp(argv[2], "minus") == 0) { 181 } else if (strcasecmp(argv[2], "minus") == 0) {
186 data.operation = GAPS_OP_SUBTRACT; 182 data.operation = GAPS_OP_SUBTRACT;
187 } else { 183 } else {
188 return cmd_results_new(CMD_INVALID, "gaps", 184 return cmd_results_new(CMD_INVALID, "Expected %s", expected_runtime);
189 "Expected %s", expected_runtime);
190 } 185 }
191 186
192 char *end; 187 char *end;
193 data.amount = strtol(argv[3], &end, 10); 188 data.amount = strtol(argv[3], &end, 10);
194 if (strlen(end) && strcasecmp(end, "px") != 0) { 189 if (strlen(end) && strcasecmp(end, "px") != 0) {
195 return cmd_results_new(CMD_INVALID, "gaps", 190 return cmd_results_new(CMD_INVALID, "Expected %s", expected_runtime);
196 "Expected %s", expected_runtime);
197 } 191 }
198 192
199 if (all) { 193 if (all) {
@@ -202,7 +196,7 @@ static struct cmd_results *gaps_set_runtime(int argc, char **argv) {
202 configure_gaps(config->handler_context.workspace, &data); 196 configure_gaps(config->handler_context.workspace, &data);
203 } 197 }
204 198
205 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 199 return cmd_results_new(CMD_SUCCESS, NULL);
206} 200}
207 201
208// gaps inner|outer|<dir>|<side> <px> - sets defaults for workspaces 202// gaps inner|outer|<dir>|<side> <px> - sets defaults for workspaces
@@ -224,9 +218,8 @@ struct cmd_results *cmd_gaps(int argc, char **argv) {
224 return gaps_set_runtime(argc, argv); 218 return gaps_set_runtime(argc, argv);
225 } 219 }
226 if (config_loading) { 220 if (config_loading) {
227 return cmd_results_new(CMD_INVALID, "gaps", 221 return cmd_results_new(CMD_INVALID, "Expected %s", expected_defaults);
228 "Expected %s", expected_defaults);
229 } 222 }
230 return cmd_results_new(CMD_INVALID, "gaps", 223 return cmd_results_new(CMD_INVALID, "Expected %s or %s",
231 "Expected %s or %s", expected_runtime, expected_defaults); 224 expected_runtime, expected_defaults);
232} 225}
diff --git a/sway/commands/hide_edge_borders.c b/sway/commands/hide_edge_borders.c
index ea261fb1..84a217b8 100644
--- a/sway/commands/hide_edge_borders.c
+++ b/sway/commands/hide_edge_borders.c
@@ -22,13 +22,12 @@ struct cmd_results *cmd_hide_edge_borders(int argc, char **argv) {
22 } else if (strcmp(argv[0], "smart_no_gaps") == 0) { 22 } else if (strcmp(argv[0], "smart_no_gaps") == 0) {
23 config->hide_edge_borders = E_SMART_NO_GAPS; 23 config->hide_edge_borders = E_SMART_NO_GAPS;
24 } else { 24 } else {
25 return cmd_results_new(CMD_INVALID, "hide_edge_borders", 25 return cmd_results_new(CMD_INVALID, "Expected 'hide_edge_borders "
26 "Expected 'hide_edge_borders "
27 "<none|vertical|horizontal|both|smart|smart_no_gaps>'"); 26 "<none|vertical|horizontal|both|smart|smart_no_gaps>'");
28 } 27 }
29 config->saved_edge_borders = config->hide_edge_borders; 28 config->saved_edge_borders = config->hide_edge_borders;
30 29
31 arrange_root(); 30 arrange_root();
32 31
33 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 32 return cmd_results_new(CMD_SUCCESS, NULL);
34} 33}
diff --git a/sway/commands/include.c b/sway/commands/include.c
index 61f383bb..d1809856 100644
--- a/sway/commands/include.c
+++ b/sway/commands/include.c
@@ -9,9 +9,9 @@ struct cmd_results *cmd_include(int argc, char **argv) {
9 9
10 if (!load_include_configs(argv[0], config, 10 if (!load_include_configs(argv[0], config,
11 &config->swaynag_config_errors)) { 11 &config->swaynag_config_errors)) {
12 return cmd_results_new(CMD_INVALID, "include", 12 return cmd_results_new(CMD_INVALID,
13 "Failed to include sub configuration file: %s", argv[0]); 13 "Failed to include sub configuration file: %s", argv[0]);
14 } 14 }
15 15
16 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 16 return cmd_results_new(CMD_SUCCESS, NULL);
17} 17}
diff --git a/sway/commands/input.c b/sway/commands/input.c
index b5765c38..1f77507a 100644
--- a/sway/commands/input.c
+++ b/sway/commands/input.c
@@ -49,7 +49,7 @@ struct cmd_results *cmd_input(int argc, char **argv) {
49 49
50 config->handler_context.input_config = new_input_config(argv[0]); 50 config->handler_context.input_config = new_input_config(argv[0]);
51 if (!config->handler_context.input_config) { 51 if (!config->handler_context.input_config) {
52 return cmd_results_new(CMD_FAILURE, NULL, "Couldn't allocate config"); 52 return cmd_results_new(CMD_FAILURE, "Couldn't allocate config");
53 } 53 }
54 54
55 struct cmd_results *res; 55 struct cmd_results *res;
@@ -60,7 +60,7 @@ struct cmd_results *cmd_input(int argc, char **argv) {
60 res = config_subcommand(argv + 1, argc - 1, 60 res = config_subcommand(argv + 1, argc - 1,
61 input_config_handlers, sizeof(input_config_handlers)); 61 input_config_handlers, sizeof(input_config_handlers));
62 } else { 62 } else {
63 res = cmd_results_new(CMD_FAILURE, "input", 63 res = cmd_results_new(CMD_FAILURE,
64 "Can only be used in config file."); 64 "Can only be used in config file.");
65 } 65 }
66 } else { 66 } else {
diff --git a/sway/commands/input/accel_profile.c b/sway/commands/input/accel_profile.c
index f7016790..08f324cc 100644
--- a/sway/commands/input/accel_profile.c
+++ b/sway/commands/input/accel_profile.c
@@ -11,8 +11,7 @@ struct cmd_results *input_cmd_accel_profile(int argc, char **argv) {
11 } 11 }
12 struct input_config *ic = config->handler_context.input_config; 12 struct input_config *ic = config->handler_context.input_config;
13 if (!ic) { 13 if (!ic) {
14 return cmd_results_new(CMD_FAILURE, "accel_profile", 14 return cmd_results_new(CMD_FAILURE, "No input device defined.");
15 "No input device defined.");
16 } 15 }
17 16
18 if (strcasecmp(argv[0], "adaptive") == 0) { 17 if (strcasecmp(argv[0], "adaptive") == 0) {
@@ -20,9 +19,9 @@ struct cmd_results *input_cmd_accel_profile(int argc, char **argv) {
20 } else if (strcasecmp(argv[0], "flat") == 0) { 19 } else if (strcasecmp(argv[0], "flat") == 0) {
21 ic->accel_profile = LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT; 20 ic->accel_profile = LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT;
22 } else { 21 } else {
23 return cmd_results_new(CMD_INVALID, "accel_profile", 22 return cmd_results_new(CMD_INVALID,
24 "Expected 'accel_profile <adaptive|flat>'"); 23 "Expected 'accel_profile <adaptive|flat>'");
25 } 24 }
26 25
27 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 26 return cmd_results_new(CMD_SUCCESS, NULL);
28} 27}
diff --git a/sway/commands/input/click_method.c b/sway/commands/input/click_method.c
index 24777475..03fcb458 100644
--- a/sway/commands/input/click_method.c
+++ b/sway/commands/input/click_method.c
@@ -12,8 +12,7 @@ struct cmd_results *input_cmd_click_method(int argc, char **argv) {
12 } 12 }
13 struct input_config *ic = config->handler_context.input_config; 13 struct input_config *ic = config->handler_context.input_config;
14 if (!ic) { 14 if (!ic) {
15 return cmd_results_new(CMD_FAILURE, "click_method", 15 return cmd_results_new(CMD_FAILURE, "No input device defined.");
16 "No input device defined.");
17 } 16 }
18 17
19 if (strcasecmp(argv[0], "none") == 0) { 18 if (strcasecmp(argv[0], "none") == 0) {
@@ -23,9 +22,9 @@ struct cmd_results *input_cmd_click_method(int argc, char **argv) {
23 } else if (strcasecmp(argv[0], "clickfinger") == 0) { 22 } else if (strcasecmp(argv[0], "clickfinger") == 0) {
24 ic->click_method = LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER; 23 ic->click_method = LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER;
25 } else { 24 } else {
26 return cmd_results_new(CMD_INVALID, "click_method", 25 return cmd_results_new(CMD_INVALID,
27 "Expected 'click_method <none|button_areas|clickfinger'>"); 26 "Expected 'click_method <none|button_areas|clickfinger'>");
28 } 27 }
29 28
30 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 29 return cmd_results_new(CMD_SUCCESS, NULL);
31} 30}
diff --git a/sway/commands/input/drag.c b/sway/commands/input/drag.c
index e325df29..062357d4 100644
--- a/sway/commands/input/drag.c
+++ b/sway/commands/input/drag.c
@@ -12,8 +12,7 @@ struct cmd_results *input_cmd_drag(int argc, char **argv) {
12 } 12 }
13 struct input_config *ic = config->handler_context.input_config; 13 struct input_config *ic = config->handler_context.input_config;
14 if (!ic) { 14 if (!ic) {
15 return cmd_results_new(CMD_FAILURE, 15 return cmd_results_new(CMD_FAILURE, "No input device defined.");
16 "drag", "No input device defined.");
17 } 16 }
18 17
19 if (parse_boolean(argv[0], true)) { 18 if (parse_boolean(argv[0], true)) {
@@ -22,5 +21,5 @@ struct cmd_results *input_cmd_drag(int argc, char **argv) {
22 ic->drag = LIBINPUT_CONFIG_DRAG_DISABLED; 21 ic->drag = LIBINPUT_CONFIG_DRAG_DISABLED;
23 } 22 }
24 23
25 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 24 return cmd_results_new(CMD_SUCCESS, NULL);
26} 25}
diff --git a/sway/commands/input/drag_lock.c b/sway/commands/input/drag_lock.c
index db5d5afa..24c548e2 100644
--- a/sway/commands/input/drag_lock.c
+++ b/sway/commands/input/drag_lock.c
@@ -12,8 +12,7 @@ struct cmd_results *input_cmd_drag_lock(int argc, char **argv) {
12 } 12 }
13 struct input_config *ic = config->handler_context.input_config; 13 struct input_config *ic = config->handler_context.input_config;
14 if (!ic) { 14 if (!ic) {
15 return cmd_results_new(CMD_FAILURE, 15 return cmd_results_new(CMD_FAILURE, "No input device defined.");
16 "drag_lock", "No input device defined.");
17 } 16 }
18 17
19 if (parse_boolean(argv[0], true)) { 18 if (parse_boolean(argv[0], true)) {
@@ -22,5 +21,5 @@ struct cmd_results *input_cmd_drag_lock(int argc, char **argv) {
22 ic->drag_lock = LIBINPUT_CONFIG_DRAG_LOCK_DISABLED; 21 ic->drag_lock = LIBINPUT_CONFIG_DRAG_LOCK_DISABLED;
23 } 22 }
24 23
25 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 24 return cmd_results_new(CMD_SUCCESS, NULL);
26} 25}
diff --git a/sway/commands/input/dwt.c b/sway/commands/input/dwt.c
index 0c3881dd..a7a4e494 100644
--- a/sway/commands/input/dwt.c
+++ b/sway/commands/input/dwt.c
@@ -12,7 +12,7 @@ struct cmd_results *input_cmd_dwt(int argc, char **argv) {
12 } 12 }
13 struct input_config *ic = config->handler_context.input_config; 13 struct input_config *ic = config->handler_context.input_config;
14 if (!ic) { 14 if (!ic) {
15 return cmd_results_new(CMD_FAILURE, "dwt", "No input device defined."); 15 return cmd_results_new(CMD_FAILURE, "No input device defined.");
16 } 16 }
17 17
18 if (parse_boolean(argv[0], true)) { 18 if (parse_boolean(argv[0], true)) {
@@ -21,5 +21,5 @@ struct cmd_results *input_cmd_dwt(int argc, char **argv) {
21 ic->dwt = LIBINPUT_CONFIG_DWT_DISABLED; 21 ic->dwt = LIBINPUT_CONFIG_DWT_DISABLED;
22 } 22 }
23 23
24 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 24 return cmd_results_new(CMD_SUCCESS, NULL);
25} 25}
diff --git a/sway/commands/input/events.c b/sway/commands/input/events.c
index 69f46269..2c6505d8 100644
--- a/sway/commands/input/events.c
+++ b/sway/commands/input/events.c
@@ -71,8 +71,7 @@ struct cmd_results *input_cmd_events(int argc, char **argv) {
71 } 71 }
72 struct input_config *ic = config->handler_context.input_config; 72 struct input_config *ic = config->handler_context.input_config;
73 if (!ic) { 73 if (!ic) {
74 return cmd_results_new(CMD_FAILURE, "events", 74 return cmd_results_new(CMD_FAILURE, "No input device defined.");
75 "No input device defined.");
76 } 75 }
77 76
78 if (strcasecmp(argv[0], "enabled") == 0) { 77 if (strcasecmp(argv[0], "enabled") == 0) {
@@ -83,7 +82,7 @@ struct cmd_results *input_cmd_events(int argc, char **argv) {
83 ic->send_events = 82 ic->send_events =
84 LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE; 83 LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE;
85 } else if (config->reading) { 84 } else if (config->reading) {
86 return cmd_results_new(CMD_INVALID, "events", 85 return cmd_results_new(CMD_INVALID,
87 "Expected 'events <enabled|disabled|disabled_on_external_mouse>'"); 86 "Expected 'events <enabled|disabled|disabled_on_external_mouse>'");
88 } else if (strcasecmp(argv[0], "toggle") == 0) { 87 } else if (strcasecmp(argv[0], "toggle") == 0) {
89 if (strcmp(ic->identifier, "*") == 0) { 88 if (strcmp(ic->identifier, "*") == 0) {
@@ -97,10 +96,10 @@ struct cmd_results *input_cmd_events(int argc, char **argv) {
97 toggle_send_events(ic); 96 toggle_send_events(ic);
98 } 97 }
99 } else { 98 } else {
100 return cmd_results_new(CMD_INVALID, "events", 99 return cmd_results_new(CMD_INVALID,
101 "Expected 'events <enabled|disabled|disabled_on_external_mouse|" 100 "Expected 'events <enabled|disabled|disabled_on_external_mouse|"
102 "toggle>'"); 101 "toggle>'");
103 } 102 }
104 103
105 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 104 return cmd_results_new(CMD_SUCCESS, NULL);
106} 105}
diff --git a/sway/commands/input/left_handed.c b/sway/commands/input/left_handed.c
index 2e0f757b..93d8d56d 100644
--- a/sway/commands/input/left_handed.c
+++ b/sway/commands/input/left_handed.c
@@ -12,11 +12,10 @@ struct cmd_results *input_cmd_left_handed(int argc, char **argv) {
12 } 12 }
13 struct input_config *ic = config->handler_context.input_config; 13 struct input_config *ic = config->handler_context.input_config;
14 if (!ic) { 14 if (!ic) {
15 return cmd_results_new(CMD_FAILURE, "left_handed", 15 return cmd_results_new(CMD_FAILURE, "No input device defined.");
16 "No input device defined.");
17 } 16 }
18 17
19 ic->left_handed = parse_boolean(argv[0], true); 18 ic->left_handed = parse_boolean(argv[0], true);
20 19
21 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 20 return cmd_results_new(CMD_SUCCESS, NULL);
22} 21}
diff --git a/sway/commands/input/map_from_region.c b/sway/commands/input/map_from_region.c
index 53608a67..de00b714 100644
--- a/sway/commands/input/map_from_region.c
+++ b/sway/commands/input/map_from_region.c
@@ -40,8 +40,7 @@ struct cmd_results *input_cmd_map_from_region(int argc, char **argv) {
40 } 40 }
41 struct input_config *ic = config->handler_context.input_config; 41 struct input_config *ic = config->handler_context.input_config;
42 if (!ic) { 42 if (!ic) {
43 return cmd_results_new(CMD_FAILURE, "map_from_region", 43 return cmd_results_new(CMD_FAILURE, "No input device defined");
44 "No input device defined");
45 } 44 }
46 45
47 ic->mapped_from_region = 46 ic->mapped_from_region =
@@ -52,30 +51,27 @@ struct cmd_results *input_cmd_map_from_region(int argc, char **argv) {
52 &ic->mapped_from_region->y1, &mm1)) { 51 &ic->mapped_from_region->y1, &mm1)) {
53 free(ic->mapped_from_region); 52 free(ic->mapped_from_region);
54 ic->mapped_from_region = NULL; 53 ic->mapped_from_region = NULL;
55 return cmd_results_new(CMD_FAILURE, "map_from_region", 54 return cmd_results_new(CMD_FAILURE, "Invalid top-left coordinates");
56 "Invalid top-left coordinates");
57 } 55 }
58 if (!parse_coords(argv[1], &ic->mapped_from_region->x2, 56 if (!parse_coords(argv[1], &ic->mapped_from_region->x2,
59 &ic->mapped_from_region->y2, &mm2)) { 57 &ic->mapped_from_region->y2, &mm2)) {
60 free(ic->mapped_from_region); 58 free(ic->mapped_from_region);
61 ic->mapped_from_region = NULL; 59 ic->mapped_from_region = NULL;
62 return cmd_results_new(CMD_FAILURE, "map_from_region", 60 return cmd_results_new(CMD_FAILURE, "Invalid bottom-right coordinates");
63 "Invalid bottom-right coordinates");
64 } 61 }
65 if (ic->mapped_from_region->x1 > ic->mapped_from_region->x2 || 62 if (ic->mapped_from_region->x1 > ic->mapped_from_region->x2 ||
66 ic->mapped_from_region->y1 > ic->mapped_from_region->y2) { 63 ic->mapped_from_region->y1 > ic->mapped_from_region->y2) {
67 free(ic->mapped_from_region); 64 free(ic->mapped_from_region);
68 ic->mapped_from_region = NULL; 65 ic->mapped_from_region = NULL;
69 return cmd_results_new(CMD_FAILURE, "map_from_region", 66 return cmd_results_new(CMD_FAILURE, "Invalid rectangle");
70 "Invalid rectangle");
71 } 67 }
72 if (mm1 != mm2) { 68 if (mm1 != mm2) {
73 free(ic->mapped_from_region); 69 free(ic->mapped_from_region);
74 ic->mapped_from_region = NULL; 70 ic->mapped_from_region = NULL;
75 return cmd_results_new(CMD_FAILURE, "map_from_region", 71 return cmd_results_new(CMD_FAILURE,
76 "Both coordinates must be in the same unit"); 72 "Both coordinates must be in the same unit");
77 } 73 }
78 ic->mapped_from_region->mm = mm1; 74 ic->mapped_from_region->mm = mm1;
79 75
80 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 76 return cmd_results_new(CMD_SUCCESS, NULL);
81} 77}
diff --git a/sway/commands/input/map_to_output.c b/sway/commands/input/map_to_output.c
index 8b16c557..6d623186 100644
--- a/sway/commands/input/map_to_output.c
+++ b/sway/commands/input/map_to_output.c
@@ -13,11 +13,10 @@ struct cmd_results *input_cmd_map_to_output(int argc, char **argv) {
13 } 13 }
14 struct input_config *ic = config->handler_context.input_config; 14 struct input_config *ic = config->handler_context.input_config;
15 if (!ic) { 15 if (!ic) {
16 return cmd_results_new(CMD_FAILURE, "map_to_output", 16 return cmd_results_new(CMD_FAILURE, "No input device defined.");
17 "No input device defined.");
18 } 17 }
19 18
20 ic->mapped_to_output = strdup(argv[0]); 19 ic->mapped_to_output = strdup(argv[0]);
21 20
22 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 21 return cmd_results_new(CMD_SUCCESS, NULL);
23} 22}
diff --git a/sway/commands/input/middle_emulation.c b/sway/commands/input/middle_emulation.c
index 80d26838..9f32692e 100644
--- a/sway/commands/input/middle_emulation.c
+++ b/sway/commands/input/middle_emulation.c
@@ -12,8 +12,7 @@ struct cmd_results *input_cmd_middle_emulation(int argc, char **argv) {
12 } 12 }
13 struct input_config *ic = config->handler_context.input_config; 13 struct input_config *ic = config->handler_context.input_config;
14 if (!ic) { 14 if (!ic) {
15 return cmd_results_new(CMD_FAILURE, "middle_emulation", 15 return cmd_results_new(CMD_FAILURE, "No input device defined.");
16 "No input device defined.");
17 } 16 }
18 17
19 if (parse_boolean(argv[0], true)) { 18 if (parse_boolean(argv[0], true)) {
@@ -22,5 +21,5 @@ struct cmd_results *input_cmd_middle_emulation(int argc, char **argv) {
22 ic->middle_emulation = LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED; 21 ic->middle_emulation = LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED;
23 } 22 }
24 23
25 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 24 return cmd_results_new(CMD_SUCCESS, NULL);
26} 25}
diff --git a/sway/commands/input/natural_scroll.c b/sway/commands/input/natural_scroll.c
index e2a93500..dec32a5b 100644
--- a/sway/commands/input/natural_scroll.c
+++ b/sway/commands/input/natural_scroll.c
@@ -12,11 +12,10 @@ struct cmd_results *input_cmd_natural_scroll(int argc, char **argv) {
12 } 12 }
13 struct input_config *ic = config->handler_context.input_config; 13 struct input_config *ic = config->handler_context.input_config;
14 if (!ic) { 14 if (!ic) {
15 return cmd_results_new(CMD_FAILURE, "natural_scoll", 15 return cmd_results_new(CMD_FAILURE, "No input device defined.");
16 "No input device defined.");
17 } 16 }
18 17
19 ic->natural_scroll = parse_boolean(argv[0], true); 18 ic->natural_scroll = parse_boolean(argv[0], true);
20 19
21 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 20 return cmd_results_new(CMD_SUCCESS, NULL);
22} 21}
diff --git a/sway/commands/input/pointer_accel.c b/sway/commands/input/pointer_accel.c
index efd81ee6..e214b32f 100644
--- a/sway/commands/input/pointer_accel.c
+++ b/sway/commands/input/pointer_accel.c
@@ -13,19 +13,17 @@ struct cmd_results *input_cmd_pointer_accel(int argc, char **argv) {
13 } 13 }
14 struct input_config *ic = config->handler_context.input_config; 14 struct input_config *ic = config->handler_context.input_config;
15 if (!ic) { 15 if (!ic) {
16 return cmd_results_new(CMD_FAILURE, 16 return cmd_results_new(CMD_FAILURE, "No input device defined.");
17 "pointer_accel", "No input device defined.");
18 } 17 }
19 18
20 float pointer_accel = parse_float(argv[0]); 19 float pointer_accel = parse_float(argv[0]);
21 if (isnan(pointer_accel)) { 20 if (isnan(pointer_accel)) {
22 return cmd_results_new(CMD_INVALID, "pointer_accel", 21 return cmd_results_new(CMD_INVALID,
23 "Invalid pointer accel; expected float."); 22 "Invalid pointer accel; expected float.");
24 } if (pointer_accel < -1 || pointer_accel > 1) { 23 } if (pointer_accel < -1 || pointer_accel > 1) {
25 return cmd_results_new(CMD_INVALID, "pointer_accel", 24 return cmd_results_new(CMD_INVALID, "Input out of range [-1, 1]");
26 "Input out of range [-1, 1]");
27 } 25 }
28 ic->pointer_accel = pointer_accel; 26 ic->pointer_accel = pointer_accel;
29 27
30 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 28 return cmd_results_new(CMD_SUCCESS, NULL);
31} 29}
diff --git a/sway/commands/input/repeat_delay.c b/sway/commands/input/repeat_delay.c
index d94b3e4d..5b787fe6 100644
--- a/sway/commands/input/repeat_delay.c
+++ b/sway/commands/input/repeat_delay.c
@@ -11,16 +11,14 @@ struct cmd_results *input_cmd_repeat_delay(int argc, char **argv) {
11 } 11 }
12 struct input_config *ic = config->handler_context.input_config; 12 struct input_config *ic = config->handler_context.input_config;
13 if (!ic) { 13 if (!ic) {
14 return cmd_results_new(CMD_FAILURE, 14 return cmd_results_new(CMD_FAILURE, "No input device defined.");
15 "repeat_delay", "No input device defined.");
16 } 15 }
17 16
18 int repeat_delay = atoi(argv[0]); 17 int repeat_delay = atoi(argv[0]);
19 if (repeat_delay < 0) { 18 if (repeat_delay < 0) {
20 return cmd_results_new(CMD_INVALID, "repeat_delay", 19 return cmd_results_new(CMD_INVALID, "Repeat delay cannot be negative");
21 "Repeat delay cannot be negative");
22 } 20 }
23 ic->repeat_delay = repeat_delay; 21 ic->repeat_delay = repeat_delay;
24 22
25 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 23 return cmd_results_new(CMD_SUCCESS, NULL);
26} 24}
diff --git a/sway/commands/input/repeat_rate.c b/sway/commands/input/repeat_rate.c
index ebec4cdb..79c5efe2 100644
--- a/sway/commands/input/repeat_rate.c
+++ b/sway/commands/input/repeat_rate.c
@@ -11,16 +11,14 @@ struct cmd_results *input_cmd_repeat_rate(int argc, char **argv) {
11 } 11 }
12 struct input_config *ic = config->handler_context.input_config; 12 struct input_config *ic = config->handler_context.input_config;
13 if (!ic) { 13 if (!ic) {
14 return cmd_results_new(CMD_FAILURE, 14 return cmd_results_new(CMD_FAILURE, "No input device defined.");
15 "repeat_rate", "No input device defined.");
16 } 15 }
17 16
18 int repeat_rate = atoi(argv[0]); 17 int repeat_rate = atoi(argv[0]);
19 if (repeat_rate < 0) { 18 if (repeat_rate < 0) {
20 return cmd_results_new(CMD_INVALID, "repeat_rate", 19 return cmd_results_new(CMD_INVALID, "Repeat rate cannot be negative");
21 "Repeat rate cannot be negative");
22 } 20 }
23 ic->repeat_rate = repeat_rate; 21 ic->repeat_rate = repeat_rate;
24 22
25 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 23 return cmd_results_new(CMD_SUCCESS, NULL);
26} 24}
diff --git a/sway/commands/input/scroll_button.c b/sway/commands/input/scroll_button.c
index d82a1fe1..6b331419 100644
--- a/sway/commands/input/scroll_button.c
+++ b/sway/commands/input/scroll_button.c
@@ -10,30 +10,28 @@ struct cmd_results *input_cmd_scroll_button(int argc, char **argv) {
10 } 10 }
11 struct input_config *ic = config->handler_context.input_config; 11 struct input_config *ic = config->handler_context.input_config;
12 if (!ic) { 12 if (!ic) {
13 return cmd_results_new(CMD_FAILURE, "scroll_button", 13 return cmd_results_new(CMD_FAILURE, "No input device defined.");
14 "No input device defined.");
15 } 14 }
16 15
17 if (strcmp(*argv, "disable") == 0) { 16 if (strcmp(*argv, "disable") == 0) {
18 ic->scroll_button = 0; 17 ic->scroll_button = 0;
19 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 18 return cmd_results_new(CMD_SUCCESS, NULL);
20 } 19 }
21 20
22 char *message = NULL; 21 char *message = NULL;
23 uint32_t button = get_mouse_button(*argv, &message); 22 uint32_t button = get_mouse_button(*argv, &message);
24 if (message) { 23 if (message) {
25 error = cmd_results_new(CMD_INVALID, "scroll_button", message); 24 error = cmd_results_new(CMD_INVALID, message);
26 free(message); 25 free(message);
27 return error; 26 return error;
28 } else if (button == SWAY_SCROLL_UP || button == SWAY_SCROLL_DOWN 27 } else if (button == SWAY_SCROLL_UP || button == SWAY_SCROLL_DOWN
29 || button == SWAY_SCROLL_LEFT || button == SWAY_SCROLL_RIGHT) { 28 || button == SWAY_SCROLL_LEFT || button == SWAY_SCROLL_RIGHT) {
30 return cmd_results_new(CMD_INVALID, "scroll_button", 29 return cmd_results_new(CMD_INVALID,
31 "X11 axis buttons are not supported for scroll_button"); 30 "X11 axis buttons are not supported for scroll_button");
32 } else if (!button) { 31 } else if (!button) {
33 return cmd_results_new(CMD_INVALID, "scroll_button", 32 return cmd_results_new(CMD_INVALID, "Unknown button %s", *argv);
34 "Unknown button %s", *argv);
35 } 33 }
36 ic->scroll_button = button; 34 ic->scroll_button = button;
37 35
38 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 36 return cmd_results_new(CMD_SUCCESS, NULL);
39} 37}
diff --git a/sway/commands/input/scroll_factor.c b/sway/commands/input/scroll_factor.c
index 52d943b0..4b72b6fa 100644
--- a/sway/commands/input/scroll_factor.c
+++ b/sway/commands/input/scroll_factor.c
@@ -14,19 +14,18 @@ struct cmd_results *input_cmd_scroll_factor(int argc, char **argv) {
14 } 14 }
15 struct input_config *ic = config->handler_context.input_config; 15 struct input_config *ic = config->handler_context.input_config;
16 if (!ic) { 16 if (!ic) {
17 return cmd_results_new(CMD_FAILURE, 17 return cmd_results_new(CMD_FAILURE, "No input device defined.");
18 "scroll_factor", "No input device defined.");
19 } 18 }
20 19
21 float scroll_factor = parse_float(argv[0]); 20 float scroll_factor = parse_float(argv[0]);
22 if (isnan(scroll_factor)) { 21 if (isnan(scroll_factor)) {
23 return cmd_results_new(CMD_INVALID, "scroll_factor", 22 return cmd_results_new(CMD_INVALID,
24 "Invalid scroll factor; expected float."); 23 "Invalid scroll factor; expected float.");
25 } else if (scroll_factor < 0) { 24 } else if (scroll_factor < 0) {
26 return cmd_results_new(CMD_INVALID, "scroll_factor", 25 return cmd_results_new(CMD_INVALID,
27 "Scroll factor cannot be negative."); 26 "Scroll factor cannot be negative.");
28 } 27 }
29 ic->scroll_factor = scroll_factor; 28 ic->scroll_factor = scroll_factor;
30 29
31 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 30 return cmd_results_new(CMD_SUCCESS, NULL);
32} 31}
diff --git a/sway/commands/input/scroll_method.c b/sway/commands/input/scroll_method.c
index c116b052..cd8b5f7a 100644
--- a/sway/commands/input/scroll_method.c
+++ b/sway/commands/input/scroll_method.c
@@ -11,8 +11,7 @@ struct cmd_results *input_cmd_scroll_method(int argc, char **argv) {
11 } 11 }
12 struct input_config *ic = config->handler_context.input_config; 12 struct input_config *ic = config->handler_context.input_config;
13 if (!ic) { 13 if (!ic) {
14 return cmd_results_new(CMD_FAILURE, "scroll_method", 14 return cmd_results_new(CMD_FAILURE, "No input device defined.");
15 "No input device defined.");
16 } 15 }
17 16
18 if (strcasecmp(argv[0], "none") == 0) { 17 if (strcasecmp(argv[0], "none") == 0) {
@@ -24,9 +23,9 @@ struct cmd_results *input_cmd_scroll_method(int argc, char **argv) {
24 } else if (strcasecmp(argv[0], "on_button_down") == 0) { 23 } else if (strcasecmp(argv[0], "on_button_down") == 0) {
25 ic->scroll_method = LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN; 24 ic->scroll_method = LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN;
26 } else { 25 } else {
27 return cmd_results_new(CMD_INVALID, "scroll_method", 26 return cmd_results_new(CMD_INVALID,
28 "Expected 'scroll_method <none|two_finger|edge|on_button_down>'"); 27 "Expected 'scroll_method <none|two_finger|edge|on_button_down>'");
29 } 28 }
30 29
31 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 30 return cmd_results_new(CMD_SUCCESS, NULL);
32} 31}
diff --git a/sway/commands/input/tap.c b/sway/commands/input/tap.c
index c455b696..443fd49d 100644
--- a/sway/commands/input/tap.c
+++ b/sway/commands/input/tap.c
@@ -13,7 +13,7 @@ struct cmd_results *input_cmd_tap(int argc, char **argv) {
13 } 13 }
14 struct input_config *ic = config->handler_context.input_config; 14 struct input_config *ic = config->handler_context.input_config;
15 if (!ic) { 15 if (!ic) {
16 return cmd_results_new(CMD_FAILURE, "tap", "No input device defined."); 16 return cmd_results_new(CMD_FAILURE, "No input device defined.");
17 } 17 }
18 18
19 if (parse_boolean(argv[0], true)) { 19 if (parse_boolean(argv[0], true)) {
@@ -22,5 +22,5 @@ struct cmd_results *input_cmd_tap(int argc, char **argv) {
22 ic->tap = LIBINPUT_CONFIG_TAP_DISABLED; 22 ic->tap = LIBINPUT_CONFIG_TAP_DISABLED;
23 } 23 }
24 24
25 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 25 return cmd_results_new(CMD_SUCCESS, NULL);
26} 26}
diff --git a/sway/commands/input/tap_button_map.c b/sway/commands/input/tap_button_map.c
index dff2985b..77ac6de7 100644
--- a/sway/commands/input/tap_button_map.c
+++ b/sway/commands/input/tap_button_map.c
@@ -11,8 +11,7 @@ struct cmd_results *input_cmd_tap_button_map(int argc, char **argv) {
11 } 11 }
12 struct input_config *ic = config->handler_context.input_config; 12 struct input_config *ic = config->handler_context.input_config;
13 if (!ic) { 13 if (!ic) {
14 return cmd_results_new(CMD_FAILURE, "tap_button_map", 14 return cmd_results_new(CMD_FAILURE, "No input device defined.");
15 "No input device defined.");
16 } 15 }
17 16
18 if (strcasecmp(argv[0], "lrm") == 0) { 17 if (strcasecmp(argv[0], "lrm") == 0) {
@@ -20,9 +19,9 @@ struct cmd_results *input_cmd_tap_button_map(int argc, char **argv) {
20 } else if (strcasecmp(argv[0], "lmr") == 0) { 19 } else if (strcasecmp(argv[0], "lmr") == 0) {
21 ic->tap_button_map = LIBINPUT_CONFIG_TAP_MAP_LMR; 20 ic->tap_button_map = LIBINPUT_CONFIG_TAP_MAP_LMR;
22 } else { 21 } else {
23 return cmd_results_new(CMD_INVALID, "tap_button_map", 22 return cmd_results_new(CMD_INVALID,
24 "Expected 'tap_button_map <lrm|lmr>'"); 23 "Expected 'tap_button_map <lrm|lmr>'");
25 } 24 }
26 25
27 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 26 return cmd_results_new(CMD_SUCCESS, NULL);
28} 27}
diff --git a/sway/commands/input/xkb_capslock.c b/sway/commands/input/xkb_capslock.c
index a939c72f..7ce98ebb 100644
--- a/sway/commands/input/xkb_capslock.c
+++ b/sway/commands/input/xkb_capslock.c
@@ -12,11 +12,10 @@ struct cmd_results *input_cmd_xkb_capslock(int argc, char **argv) {
12 } 12 }
13 struct input_config *ic = config->handler_context.input_config; 13 struct input_config *ic = config->handler_context.input_config;
14 if (!ic) { 14 if (!ic) {
15 return cmd_results_new(CMD_FAILURE, "xkb_capslock", 15 return cmd_results_new(CMD_FAILURE, "No input device defined.");
16 "No input device defined.");
17 } 16 }
18 17
19 ic->xkb_capslock = parse_boolean(argv[0], false); 18 ic->xkb_capslock = parse_boolean(argv[0], false);
20 19
21 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 20 return cmd_results_new(CMD_SUCCESS, NULL);
22} 21}
diff --git a/sway/commands/input/xkb_layout.c b/sway/commands/input/xkb_layout.c
index 43166401..c9200aa2 100644
--- a/sway/commands/input/xkb_layout.c
+++ b/sway/commands/input/xkb_layout.c
@@ -11,13 +11,12 @@ struct cmd_results *input_cmd_xkb_layout(int argc, char **argv) {
11 } 11 }
12 struct input_config *ic = config->handler_context.input_config; 12 struct input_config *ic = config->handler_context.input_config;
13 if (!ic) { 13 if (!ic) {
14 return cmd_results_new(CMD_FAILURE, "xkb_layout", 14 return cmd_results_new(CMD_FAILURE, "No input device defined.");
15 "No input device defined.");
16 } 15 }
17 16
18 ic->xkb_layout = strdup(argv[0]); 17 ic->xkb_layout = strdup(argv[0]);
19 18
20 wlr_log(WLR_DEBUG, "set-xkb_layout for config: %s layout: %s", 19 wlr_log(WLR_DEBUG, "set-xkb_layout for config: %s layout: %s",
21 ic->identifier, ic->xkb_layout); 20 ic->identifier, ic->xkb_layout);
22 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 21 return cmd_results_new(CMD_SUCCESS, NULL);
23} 22}
diff --git a/sway/commands/input/xkb_model.c b/sway/commands/input/xkb_model.c
index 066f632b..763ae80e 100644
--- a/sway/commands/input/xkb_model.c
+++ b/sway/commands/input/xkb_model.c
@@ -11,13 +11,12 @@ struct cmd_results *input_cmd_xkb_model(int argc, char **argv) {
11 } 11 }
12 struct input_config *ic = config->handler_context.input_config; 12 struct input_config *ic = config->handler_context.input_config;
13 if (!ic) { 13 if (!ic) {
14 return cmd_results_new(CMD_FAILURE, "xkb_model", 14 return cmd_results_new(CMD_FAILURE, "No input device defined.");
15 "No input device defined.");
16 } 15 }
17 16
18 ic->xkb_model = strdup(argv[0]); 17 ic->xkb_model = strdup(argv[0]);
19 18
20 wlr_log(WLR_DEBUG, "set-xkb_model for config: %s model: %s", 19 wlr_log(WLR_DEBUG, "set-xkb_model for config: %s model: %s",
21 ic->identifier, ic->xkb_model); 20 ic->identifier, ic->xkb_model);
22 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 21 return cmd_results_new(CMD_SUCCESS, NULL);
23} 22}
diff --git a/sway/commands/input/xkb_numlock.c b/sway/commands/input/xkb_numlock.c
index 2e962c5b..d5b75672 100644
--- a/sway/commands/input/xkb_numlock.c
+++ b/sway/commands/input/xkb_numlock.c
@@ -12,11 +12,10 @@ struct cmd_results *input_cmd_xkb_numlock(int argc, char **argv) {
12 } 12 }
13 struct input_config *ic = config->handler_context.input_config; 13 struct input_config *ic = config->handler_context.input_config;
14 if (!ic) { 14 if (!ic) {
15 return cmd_results_new(CMD_FAILURE, "xkb_numlock", 15 return cmd_results_new(CMD_FAILURE, "No input device defined.");
16 "No input device defined.");
17 } 16 }
18 17
19 ic->xkb_numlock = parse_boolean(argv[0], false); 18 ic->xkb_numlock = parse_boolean(argv[0], false);
20 19
21 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 20 return cmd_results_new(CMD_SUCCESS, NULL);
22} 21}
diff --git a/sway/commands/input/xkb_options.c b/sway/commands/input/xkb_options.c
index 09dc4a5c..1ff6e680 100644
--- a/sway/commands/input/xkb_options.c
+++ b/sway/commands/input/xkb_options.c
@@ -11,13 +11,12 @@ struct cmd_results *input_cmd_xkb_options(int argc, char **argv) {
11 } 11 }
12 struct input_config *ic = config->handler_context.input_config; 12 struct input_config *ic = config->handler_context.input_config;
13 if (!ic) { 13 if (!ic) {
14 return cmd_results_new(CMD_FAILURE, "xkb_options", 14 return cmd_results_new(CMD_FAILURE, "No input device defined.");
15 "No input device defined.");
16 } 15 }
17 16
18 ic->xkb_options = strdup(argv[0]); 17 ic->xkb_options = strdup(argv[0]);
19 18
20 wlr_log(WLR_DEBUG, "set-xkb_options for config: %s options: %s", 19 wlr_log(WLR_DEBUG, "set-xkb_options for config: %s options: %s",
21 ic->identifier, ic->xkb_options); 20 ic->identifier, ic->xkb_options);
22 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 21 return cmd_results_new(CMD_SUCCESS, NULL);
23} 22}
diff --git a/sway/commands/input/xkb_rules.c b/sway/commands/input/xkb_rules.c
index d3e576e6..29172b24 100644
--- a/sway/commands/input/xkb_rules.c
+++ b/sway/commands/input/xkb_rules.c
@@ -11,13 +11,12 @@ struct cmd_results *input_cmd_xkb_rules(int argc, char **argv) {
11 } 11 }
12 struct input_config *ic = config->handler_context.input_config; 12 struct input_config *ic = config->handler_context.input_config;
13 if (!ic) { 13 if (!ic) {
14 return cmd_results_new(CMD_FAILURE, "xkb_rules", 14 return cmd_results_new(CMD_FAILURE, "No input device defined.");
15 "No input device defined.");
16 } 15 }
17 16
18 ic->xkb_rules = strdup(argv[0]); 17 ic->xkb_rules = strdup(argv[0]);
19 18
20 wlr_log(WLR_DEBUG, "set-xkb_rules for config: %s rules: %s", 19 wlr_log(WLR_DEBUG, "set-xkb_rules for config: %s rules: %s",
21 ic->identifier, ic->xkb_rules); 20 ic->identifier, ic->xkb_rules);
22 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 21 return cmd_results_new(CMD_SUCCESS, NULL);
23} 22}
diff --git a/sway/commands/input/xkb_variant.c b/sway/commands/input/xkb_variant.c
index 2d7581d1..9f3baed6 100644
--- a/sway/commands/input/xkb_variant.c
+++ b/sway/commands/input/xkb_variant.c
@@ -11,13 +11,12 @@ struct cmd_results *input_cmd_xkb_variant(int argc, char **argv) {
11 } 11 }
12 struct input_config *ic = config->handler_context.input_config; 12 struct input_config *ic = config->handler_context.input_config;
13 if (!ic) { 13 if (!ic) {
14 return cmd_results_new(CMD_FAILURE, "xkb_variant", 14 return cmd_results_new(CMD_FAILURE, "No input device defined.");
15 "No input device defined.");
16 } 15 }
17 16
18 ic->xkb_variant = strdup(argv[0]); 17 ic->xkb_variant = strdup(argv[0]);
19 18
20 wlr_log(WLR_DEBUG, "set-xkb_variant for config: %s variant: %s", 19 wlr_log(WLR_DEBUG, "set-xkb_variant for config: %s variant: %s",
21 ic->identifier, ic->xkb_variant); 20 ic->identifier, ic->xkb_variant);
22 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 21 return cmd_results_new(CMD_SUCCESS, NULL);
23} 22}
diff --git a/sway/commands/kill.c b/sway/commands/kill.c
index f1d75b9a..41daeb4e 100644
--- a/sway/commands/kill.c
+++ b/sway/commands/kill.c
@@ -15,7 +15,7 @@ static void close_container_iterator(struct sway_container *con, void *data) {
15 15
16struct cmd_results *cmd_kill(int argc, char **argv) { 16struct cmd_results *cmd_kill(int argc, char **argv) {
17 if (!root->outputs->length) { 17 if (!root->outputs->length) {
18 return cmd_results_new(CMD_INVALID, "kill", 18 return cmd_results_new(CMD_INVALID,
19 "Can't run this command while there's no outputs connected."); 19 "Can't run this command while there's no outputs connected.");
20 } 20 }
21 struct sway_container *con = config->handler_context.container; 21 struct sway_container *con = config->handler_context.container;
@@ -28,5 +28,5 @@ struct cmd_results *cmd_kill(int argc, char **argv) {
28 workspace_for_each_container(ws, close_container_iterator, NULL); 28 workspace_for_each_container(ws, close_container_iterator, NULL);
29 } 29 }
30 30
31 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 31 return cmd_results_new(CMD_SUCCESS, NULL);
32} 32}
diff --git a/sway/commands/layout.c b/sway/commands/layout.c
index 8fde1776..2aca31dc 100644
--- a/sway/commands/layout.c
+++ b/sway/commands/layout.c
@@ -20,7 +20,7 @@ static enum sway_container_layout parse_layout_string(char *s) {
20 return L_NONE; 20 return L_NONE;
21} 21}
22 22
23static const char* expected_syntax = 23static const char expected_syntax[] =
24 "Expected 'layout default|tabbed|stacking|splitv|splith' or " 24 "Expected 'layout default|tabbed|stacking|splitv|splith' or "
25 "'layout toggle [split|all]' or " 25 "'layout toggle [split|all]' or "
26 "'layout toggle [split|tabbed|stacking|splitv|splith] [split|tabbed|stacking|splitv|splith]...'"; 26 "'layout toggle [split|tabbed|stacking|splitv|splith] [split|tabbed|stacking|splitv|splith]...'";
@@ -100,14 +100,14 @@ struct cmd_results *cmd_layout(int argc, char **argv) {
100 return error; 100 return error;
101 } 101 }
102 if (!root->outputs->length) { 102 if (!root->outputs->length) {
103 return cmd_results_new(CMD_INVALID, "layout", 103 return cmd_results_new(CMD_INVALID,
104 "Can't run this command while there's no outputs connected."); 104 "Can't run this command while there's no outputs connected.");
105 } 105 }
106 struct sway_container *container = config->handler_context.container; 106 struct sway_container *container = config->handler_context.container;
107 struct sway_workspace *workspace = config->handler_context.workspace; 107 struct sway_workspace *workspace = config->handler_context.workspace;
108 108
109 if (container && container_is_floating(container)) { 109 if (container && container_is_floating(container)) {
110 return cmd_results_new(CMD_FAILURE, "layout", 110 return cmd_results_new(CMD_FAILURE,
111 "Unable to change layout of floating windows"); 111 "Unable to change layout of floating windows");
112 } 112 }
113 113
@@ -133,7 +133,7 @@ struct cmd_results *cmd_layout(int argc, char **argv) {
133 workspace->layout, workspace->prev_split_layout); 133 workspace->layout, workspace->prev_split_layout);
134 } 134 }
135 if (new_layout == L_NONE) { 135 if (new_layout == L_NONE) {
136 return cmd_results_new(CMD_INVALID, "layout", expected_syntax); 136 return cmd_results_new(CMD_INVALID, expected_syntax);
137 } 137 }
138 if (new_layout != old_layout) { 138 if (new_layout != old_layout) {
139 if (container) { 139 if (container) {
@@ -152,5 +152,5 @@ struct cmd_results *cmd_layout(int argc, char **argv) {
152 arrange_workspace(workspace); 152 arrange_workspace(workspace);
153 } 153 }
154 154
155 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 155 return cmd_results_new(CMD_SUCCESS, NULL);
156} 156}
diff --git a/sway/commands/mark.c b/sway/commands/mark.c
index c76e1d63..aa5f185c 100644
--- a/sway/commands/mark.c
+++ b/sway/commands/mark.c
@@ -20,8 +20,7 @@ struct cmd_results *cmd_mark(int argc, char **argv) {
20 } 20 }
21 struct sway_container *container = config->handler_context.container; 21 struct sway_container *container = config->handler_context.container;
22 if (!container) { 22 if (!container) {
23 return cmd_results_new(CMD_INVALID, "mark", 23 return cmd_results_new(CMD_INVALID, "Only containers can have marks");
24 "Only containers can have marks");
25 } 24 }
26 25
27 bool add = false, toggle = false; 26 bool add = false, toggle = false;
@@ -33,7 +32,7 @@ struct cmd_results *cmd_mark(int argc, char **argv) {
33 } else if (strcmp(*argv, "--toggle") == 0) { 32 } else if (strcmp(*argv, "--toggle") == 0) {
34 toggle = true; 33 toggle = true;
35 } else { 34 } else {
36 return cmd_results_new(CMD_INVALID, "mark", 35 return cmd_results_new(CMD_INVALID,
37 "Unrecognized argument '%s'", *argv); 36 "Unrecognized argument '%s'", *argv);
38 } 37 }
39 ++argv; 38 ++argv;
@@ -41,7 +40,7 @@ struct cmd_results *cmd_mark(int argc, char **argv) {
41 } 40 }
42 41
43 if (!argc) { 42 if (!argc) {
44 return cmd_results_new(CMD_INVALID, "mark", 43 return cmd_results_new(CMD_INVALID,
45 "Expected '[--add|--replace] [--toggle] <identifier>'"); 44 "Expected '[--add|--replace] [--toggle] <identifier>'");
46 } 45 }
47 46
@@ -65,5 +64,5 @@ struct cmd_results *cmd_mark(int argc, char **argv) {
65 view_execute_criteria(container->view); 64 view_execute_criteria(container->view);
66 } 65 }
67 66
68 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 67 return cmd_results_new(CMD_SUCCESS, NULL);
69} 68}
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
diff --git a/sway/commands/mouse_warping.c b/sway/commands/mouse_warping.c
index d067bc65..8b643f62 100644
--- a/sway/commands/mouse_warping.c
+++ b/sway/commands/mouse_warping.c
@@ -13,9 +13,9 @@ struct cmd_results *cmd_mouse_warping(int argc, char **argv) {
13 } else if (strcasecmp(argv[0], "none") == 0) { 13 } else if (strcasecmp(argv[0], "none") == 0) {
14 config->mouse_warping = WARP_NO; 14 config->mouse_warping = WARP_NO;
15 } else { 15 } else {
16 return cmd_results_new(CMD_FAILURE, "mouse_warping", 16 return cmd_results_new(CMD_FAILURE,
17 "Expected 'mouse_warping output|container|none'"); 17 "Expected 'mouse_warping output|container|none'");
18 } 18 }
19 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 19 return cmd_results_new(CMD_SUCCESS, NULL);
20} 20}
21 21
diff --git a/sway/commands/move.c b/sway/commands/move.c
index 72e177e8..d4fe2f01 100644
--- a/sway/commands/move.c
+++ b/sway/commands/move.c
@@ -21,7 +21,7 @@
21#include "log.h" 21#include "log.h"
22#include "util.h" 22#include "util.h"
23 23
24static const char *expected_syntax = 24static const char expected_syntax[] =
25 "Expected 'move <left|right|up|down> <[px] px>' or " 25 "Expected 'move <left|right|up|down> <[px] px>' or "
26 "'move [--no-auto-back-and-forth] <container|window> [to] workspace <name>' or " 26 "'move [--no-auto-back-and-forth] <container|window> [to] workspace <name>' or "
27 "'move <container|window|workspace> [to] output <name|direction>' or " 27 "'move <container|window|workspace> [to] output <name|direction>' or "
@@ -378,7 +378,7 @@ static struct cmd_results *cmd_move_container(int argc, char **argv) {
378 struct sway_container *container = config->handler_context.container; 378 struct sway_container *container = config->handler_context.container;
379 if (node->type == N_WORKSPACE) { 379 if (node->type == N_WORKSPACE) {
380 if (workspace->tiling->length == 0) { 380 if (workspace->tiling->length == 0) {
381 return cmd_results_new(CMD_FAILURE, "move", 381 return cmd_results_new(CMD_FAILURE,
382 "Can't move an empty workspace"); 382 "Can't move an empty workspace");
383 } 383 }
384 container = workspace_wrap_children(workspace); 384 container = workspace_wrap_children(workspace);
@@ -388,21 +388,21 @@ static struct cmd_results *cmd_move_container(int argc, char **argv) {
388 while (strcasecmp(argv[0], "--no-auto-back-and-forth") == 0) { 388 while (strcasecmp(argv[0], "--no-auto-back-and-forth") == 0) {
389 no_auto_back_and_forth = true; 389 no_auto_back_and_forth = true;
390 if (--argc < 3) { 390 if (--argc < 3) {
391 return cmd_results_new(CMD_INVALID, "move", expected_syntax); 391 return cmd_results_new(CMD_INVALID, expected_syntax);
392 } 392 }
393 ++argv; 393 ++argv;
394 } 394 }
395 while (strcasecmp(argv[1], "--no-auto-back-and-forth") == 0) { 395 while (strcasecmp(argv[1], "--no-auto-back-and-forth") == 0) {
396 no_auto_back_and_forth = true; 396 no_auto_back_and_forth = true;
397 if (--argc < 3) { 397 if (--argc < 3) {
398 return cmd_results_new(CMD_INVALID, "move", expected_syntax); 398 return cmd_results_new(CMD_INVALID, expected_syntax);
399 } 399 }
400 argv++; 400 argv++;
401 } 401 }
402 402
403 while (strcasecmp(argv[1], "to") == 0) { 403 while (strcasecmp(argv[1], "to") == 0) {
404 if (--argc < 3) { 404 if (--argc < 3) {
405 return cmd_results_new(CMD_INVALID, "move", expected_syntax); 405 return cmd_results_new(CMD_INVALID, expected_syntax);
406 } 406 }
407 argv++; 407 argv++;
408 } 408 }
@@ -429,7 +429,7 @@ static struct cmd_results *cmd_move_container(int argc, char **argv) {
429 if (seat->prev_workspace_name) { 429 if (seat->prev_workspace_name) {
430 ws_name = strdup(seat->prev_workspace_name); 430 ws_name = strdup(seat->prev_workspace_name);
431 } else { 431 } else {
432 return cmd_results_new(CMD_FAILURE, "move", 432 return cmd_results_new(CMD_FAILURE,
433 "No workspace was previously active."); 433 "No workspace was previously active.");
434 } 434 }
435 } 435 }
@@ -437,11 +437,10 @@ static struct cmd_results *cmd_move_container(int argc, char **argv) {
437 if (strcasecmp(argv[2], "number") == 0) { 437 if (strcasecmp(argv[2], "number") == 0) {
438 // move "container to workspace number x" 438 // move "container to workspace number x"
439 if (argc < 4) { 439 if (argc < 4) {
440 return cmd_results_new(CMD_INVALID, "move", 440 return cmd_results_new(CMD_INVALID, expected_syntax);
441 expected_syntax);
442 } 441 }
443 if (!isdigit(argv[3][0])) { 442 if (!isdigit(argv[3][0])) {
444 return cmd_results_new(CMD_INVALID, "move", 443 return cmd_results_new(CMD_INVALID,
445 "Invalid workspace number '%s'", argv[3]); 444 "Invalid workspace number '%s'", argv[3]);
446 } 445 }
447 ws_name = join_args(argv + 3, argc - 3); 446 ws_name = join_args(argv + 3, argc - 3);
@@ -472,7 +471,7 @@ static struct cmd_results *cmd_move_container(int argc, char **argv) {
472 workspace_get_initial_output(ws_name); 471 workspace_get_initial_output(ws_name);
473 if (old_output == new_output) { 472 if (old_output == new_output) {
474 free(ws_name); 473 free(ws_name);
475 return cmd_results_new(CMD_FAILURE, "move", 474 return cmd_results_new(CMD_FAILURE,
476 "Can't move sticky container to another workspace " 475 "Can't move sticky container to another workspace "
477 "on the same output"); 476 "on the same output");
478 } 477 }
@@ -486,24 +485,24 @@ static struct cmd_results *cmd_move_container(int argc, char **argv) {
486 struct sway_output *new_output = output_in_direction(argv[2], 485 struct sway_output *new_output = output_in_direction(argv[2],
487 old_output, container->x, container->y); 486 old_output, container->x, container->y);
488 if (!new_output) { 487 if (!new_output) {
489 return cmd_results_new(CMD_FAILURE, "move workspace", 488 return cmd_results_new(CMD_FAILURE,
490 "Can't find output with name/direction '%s'", argv[2]); 489 "Can't find output with name/direction '%s'", argv[2]);
491 } 490 }
492 destination = seat_get_focus_inactive(seat, &new_output->node); 491 destination = seat_get_focus_inactive(seat, &new_output->node);
493 } else if (strcasecmp(argv[1], "mark") == 0) { 492 } else if (strcasecmp(argv[1], "mark") == 0) {
494 struct sway_container *dest_con = container_find_mark(argv[2]); 493 struct sway_container *dest_con = container_find_mark(argv[2]);
495 if (dest_con == NULL) { 494 if (dest_con == NULL) {
496 return cmd_results_new(CMD_FAILURE, "move", 495 return cmd_results_new(CMD_FAILURE,
497 "Mark '%s' not found", argv[2]); 496 "Mark '%s' not found", argv[2]);
498 } 497 }
499 destination = &dest_con->node; 498 destination = &dest_con->node;
500 } else { 499 } else {
501 return cmd_results_new(CMD_INVALID, "move", expected_syntax); 500 return cmd_results_new(CMD_INVALID, expected_syntax);
502 } 501 }
503 502
504 if (container->is_sticky && old_output && 503 if (container->is_sticky && old_output &&
505 node_has_ancestor(destination, &old_output->node)) { 504 node_has_ancestor(destination, &old_output->node)) {
506 return cmd_results_new(CMD_FAILURE, "move", "Can't move sticky " 505 return cmd_results_new(CMD_FAILURE, "Can't move sticky "
507 "container to another workspace on the same output"); 506 "container to another workspace on the same output");
508 } 507 }
509 508
@@ -569,7 +568,7 @@ static struct cmd_results *cmd_move_container(int argc, char **argv) {
569 } 568 }
570 arrange_node(node_get_parent(destination)); 569 arrange_node(node_get_parent(destination));
571 570
572 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 571 return cmd_results_new(CMD_SUCCESS, NULL);
573} 572}
574 573
575static void workspace_move_to_output(struct sway_workspace *workspace, 574static void workspace_move_to_output(struct sway_workspace *workspace,
@@ -611,13 +610,13 @@ static struct cmd_results *cmd_move_workspace(int argc, char **argv) {
611 610
612 while (strcasecmp(argv[1], "to") == 0) { 611 while (strcasecmp(argv[1], "to") == 0) {
613 if (--argc < 3) { 612 if (--argc < 3) {
614 return cmd_results_new(CMD_INVALID, "move", expected_syntax); 613 return cmd_results_new(CMD_INVALID, expected_syntax);
615 } 614 }
616 ++argv; 615 ++argv;
617 } 616 }
618 617
619 if (strcasecmp(argv[1], "output") != 0) { 618 if (strcasecmp(argv[1], "output") != 0) {
620 return cmd_results_new(CMD_INVALID, "move", expected_syntax); 619 return cmd_results_new(CMD_INVALID, expected_syntax);
621 } 620 }
622 621
623 struct sway_workspace *workspace = config->handler_context.workspace; 622 struct sway_workspace *workspace = config->handler_context.workspace;
@@ -627,7 +626,7 @@ static struct cmd_results *cmd_move_workspace(int argc, char **argv) {
627 struct sway_output *new_output = output_in_direction(argv[2], 626 struct sway_output *new_output = output_in_direction(argv[2],
628 old_output, center_x, center_y); 627 old_output, center_x, center_y);
629 if (!new_output) { 628 if (!new_output) {
630 return cmd_results_new(CMD_FAILURE, "move workspace", 629 return cmd_results_new(CMD_FAILURE,
631 "Can't find output with name/direction '%s'", argv[2]); 630 "Can't find output with name/direction '%s'", argv[2]);
632 } 631 }
633 workspace_move_to_output(workspace, new_output); 632 workspace_move_to_output(workspace, new_output);
@@ -635,7 +634,7 @@ static struct cmd_results *cmd_move_workspace(int argc, char **argv) {
635 arrange_output(old_output); 634 arrange_output(old_output);
636 arrange_output(new_output); 635 arrange_output(new_output);
637 636
638 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 637 return cmd_results_new(CMD_SUCCESS, NULL);
639} 638}
640 639
641static struct cmd_results *cmd_move_in_direction( 640static struct cmd_results *cmd_move_in_direction(
@@ -645,19 +644,18 @@ static struct cmd_results *cmd_move_in_direction(
645 char *inv; 644 char *inv;
646 move_amt = (int)strtol(argv[1], &inv, 10); 645 move_amt = (int)strtol(argv[1], &inv, 10);
647 if (*inv != '\0' && strcasecmp(inv, "px") != 0) { 646 if (*inv != '\0' && strcasecmp(inv, "px") != 0) {
648 return cmd_results_new(CMD_FAILURE, "move", 647 return cmd_results_new(CMD_FAILURE, "Invalid distance specified");
649 "Invalid distance specified");
650 } 648 }
651 } 649 }
652 650
653 struct sway_container *container = config->handler_context.container; 651 struct sway_container *container = config->handler_context.container;
654 if (!container) { 652 if (!container) {
655 return cmd_results_new(CMD_FAILURE, "move", 653 return cmd_results_new(CMD_FAILURE,
656 "Cannot move workspaces in a direction"); 654 "Cannot move workspaces in a direction");
657 } 655 }
658 if (container_is_floating(container)) { 656 if (container_is_floating(container)) {
659 if (container->is_fullscreen) { 657 if (container->is_fullscreen) {
660 return cmd_results_new(CMD_FAILURE, "move", 658 return cmd_results_new(CMD_FAILURE,
661 "Cannot move fullscreen floating container"); 659 "Cannot move fullscreen floating container");
662 } 660 }
663 double lx = container->x; 661 double lx = container->x;
@@ -677,13 +675,13 @@ static struct cmd_results *cmd_move_in_direction(
677 break; 675 break;
678 } 676 }
679 container_floating_move_to(container, lx, ly); 677 container_floating_move_to(container, lx, ly);
680 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 678 return cmd_results_new(CMD_SUCCESS, NULL);
681 } 679 }
682 struct sway_workspace *old_ws = container->workspace; 680 struct sway_workspace *old_ws = container->workspace;
683 681
684 if (!container_move_in_direction(container, direction)) { 682 if (!container_move_in_direction(container, direction)) {
685 // Container didn't move 683 // Container didn't move
686 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 684 return cmd_results_new(CMD_SUCCESS, NULL);
687 } 685 }
688 686
689 struct sway_workspace *new_ws = container->workspace; 687 struct sway_workspace *new_ws = container->workspace;
@@ -708,10 +706,10 @@ static struct cmd_results *cmd_move_in_direction(
708 } 706 }
709 container_end_mouse_operation(container); 707 container_end_mouse_operation(container);
710 708
711 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 709 return cmd_results_new(CMD_SUCCESS, NULL);
712} 710}
713 711
714static const char *expected_position_syntax = 712static const char expected_position_syntax[] =
715 "Expected 'move [absolute] position <x> [px] <y> [px]' or " 713 "Expected 'move [absolute] position <x> [px] <y> [px]' or "
716 "'move [absolute] position center' or " 714 "'move [absolute] position center' or "
717 "'move position cursor|mouse|pointer'"; 715 "'move position cursor|mouse|pointer'";
@@ -719,12 +717,11 @@ static const char *expected_position_syntax =
719static struct cmd_results *cmd_move_to_position(int argc, char **argv) { 717static struct cmd_results *cmd_move_to_position(int argc, char **argv) {
720 struct sway_container *container = config->handler_context.container; 718 struct sway_container *container = config->handler_context.container;
721 if (!container || !container_is_floating(container)) { 719 if (!container || !container_is_floating(container)) {
722 return cmd_results_new(CMD_FAILURE, "move", 720 return cmd_results_new(CMD_FAILURE, "Only floating containers "
723 "Only floating containers "
724 "can be moved to an absolute position"); 721 "can be moved to an absolute position");
725 } 722 }
726 if (!argc) { 723 if (!argc) {
727 return cmd_results_new(CMD_FAILURE, "move", expected_position_syntax); 724 return cmd_results_new(CMD_FAILURE, expected_position_syntax);
728 } 725 }
729 726
730 bool absolute = false; 727 bool absolute = false;
@@ -734,25 +731,25 @@ static struct cmd_results *cmd_move_to_position(int argc, char **argv) {
734 ++argv; 731 ++argv;
735 } 732 }
736 if (!argc) { 733 if (!argc) {
737 return cmd_results_new(CMD_FAILURE, "move", expected_position_syntax); 734 return cmd_results_new(CMD_FAILURE, expected_position_syntax);
738 } 735 }
739 if (strcmp(argv[0], "position") == 0) { 736 if (strcmp(argv[0], "position") == 0) {
740 --argc; 737 --argc;
741 ++argv; 738 ++argv;
742 } 739 }
743 if (!argc) { 740 if (!argc) {
744 return cmd_results_new(CMD_FAILURE, "move", expected_position_syntax); 741 return cmd_results_new(CMD_FAILURE, expected_position_syntax);
745 } 742 }
746 if (strcmp(argv[0], "cursor") == 0 || strcmp(argv[0], "mouse") == 0 || 743 if (strcmp(argv[0], "cursor") == 0 || strcmp(argv[0], "mouse") == 0 ||
747 strcmp(argv[0], "pointer") == 0) { 744 strcmp(argv[0], "pointer") == 0) {
748 struct sway_seat *seat = config->handler_context.seat; 745 struct sway_seat *seat = config->handler_context.seat;
749 if (!seat->cursor) { 746 if (!seat->cursor) {
750 return cmd_results_new(CMD_FAILURE, "move", "No cursor device"); 747 return cmd_results_new(CMD_FAILURE, "No cursor device");
751 } 748 }
752 double lx = seat->cursor->cursor->x - container->width / 2; 749 double lx = seat->cursor->cursor->x - container->width / 2;
753 double ly = seat->cursor->cursor->y - container->height / 2; 750 double ly = seat->cursor->cursor->y - container->height / 2;
754 container_floating_move_to(container, lx, ly); 751 container_floating_move_to(container, lx, ly);
755 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 752 return cmd_results_new(CMD_SUCCESS, NULL);
756 } else if (strcmp(argv[0], "center") == 0) { 753 } else if (strcmp(argv[0], "center") == 0) {
757 double lx, ly; 754 double lx, ly;
758 if (absolute) { 755 if (absolute) {
@@ -764,19 +761,18 @@ static struct cmd_results *cmd_move_to_position(int argc, char **argv) {
764 ly = ws->y + (ws->height - container->height) / 2; 761 ly = ws->y + (ws->height - container->height) / 2;
765 } 762 }
766 container_floating_move_to(container, lx, ly); 763 container_floating_move_to(container, lx, ly);
767 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 764 return cmd_results_new(CMD_SUCCESS, NULL);
768 } 765 }
769 766
770 if (argc < 2) { 767 if (argc < 2) {
771 return cmd_results_new(CMD_FAILURE, "move", expected_position_syntax); 768 return cmd_results_new(CMD_FAILURE, expected_position_syntax);
772 } 769 }
773 770
774 double lx, ly; 771 double lx, ly;
775 char *inv; 772 char *inv;
776 lx = (double)strtol(argv[0], &inv, 10); 773 lx = (double)strtol(argv[0], &inv, 10);
777 if (*inv != '\0' && strcasecmp(inv, "px") != 0) { 774 if (*inv != '\0' && strcasecmp(inv, "px") != 0) {
778 return cmd_results_new(CMD_FAILURE, "move", 775 return cmd_results_new(CMD_FAILURE, "Invalid position specified");
779 "Invalid position specified");
780 } 776 }
781 if (strcmp(argv[1], "px") == 0) { 777 if (strcmp(argv[1], "px") == 0) {
782 --argc; 778 --argc;
@@ -784,14 +780,13 @@ static struct cmd_results *cmd_move_to_position(int argc, char **argv) {
784 } 780 }
785 781
786 if (argc > 3) { 782 if (argc > 3) {
787 return cmd_results_new(CMD_FAILURE, "move", expected_position_syntax); 783 return cmd_results_new(CMD_FAILURE, expected_position_syntax);
788 } 784 }
789 785
790 ly = (double)strtol(argv[1], &inv, 10); 786 ly = (double)strtol(argv[1], &inv, 10);
791 if ((*inv != '\0' && strcasecmp(inv, "px") != 0) || 787 if ((*inv != '\0' && strcasecmp(inv, "px") != 0) ||
792 (argc == 3 && strcmp(argv[2], "px") != 0)) { 788 (argc == 3 && strcmp(argv[2], "px") != 0)) {
793 return cmd_results_new(CMD_FAILURE, "move", 789 return cmd_results_new(CMD_FAILURE, "Invalid position specified");
794 "Invalid position specified");
795 } 790 }
796 791
797 if (!absolute) { 792 if (!absolute) {
@@ -799,7 +794,7 @@ static struct cmd_results *cmd_move_to_position(int argc, char **argv) {
799 ly += container->workspace->y; 794 ly += container->workspace->y;
800 } 795 }
801 container_floating_move_to(container, lx, ly); 796 container_floating_move_to(container, lx, ly);
802 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 797 return cmd_results_new(CMD_SUCCESS, NULL);
803} 798}
804 799
805static struct cmd_results *cmd_move_to_scratchpad(void) { 800static struct cmd_results *cmd_move_to_scratchpad(void) {
@@ -807,7 +802,7 @@ static struct cmd_results *cmd_move_to_scratchpad(void) {
807 struct sway_container *con = config->handler_context.container; 802 struct sway_container *con = config->handler_context.container;
808 struct sway_workspace *ws = config->handler_context.workspace; 803 struct sway_workspace *ws = config->handler_context.workspace;
809 if (node->type == N_WORKSPACE && ws->tiling->length == 0) { 804 if (node->type == N_WORKSPACE && ws->tiling->length == 0) {
810 return cmd_results_new(CMD_INVALID, "move", 805 return cmd_results_new(CMD_INVALID,
811 "Can't move an empty workspace to the scratchpad"); 806 "Can't move an empty workspace to the scratchpad");
812 } 807 }
813 if (node->type == N_WORKSPACE) { 808 if (node->type == N_WORKSPACE) {
@@ -825,11 +820,11 @@ static struct cmd_results *cmd_move_to_scratchpad(void) {
825 } 820 }
826 821
827 if (con->scratchpad) { 822 if (con->scratchpad) {
828 return cmd_results_new(CMD_INVALID, "move", 823 return cmd_results_new(CMD_INVALID,
829 "Container is already in the scratchpad"); 824 "Container is already in the scratchpad");
830 } 825 }
831 root_scratchpad_add_container(con); 826 root_scratchpad_add_container(con);
832 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 827 return cmd_results_new(CMD_SUCCESS, NULL);
833} 828}
834 829
835struct cmd_results *cmd_move(int argc, char **argv) { 830struct cmd_results *cmd_move(int argc, char **argv) {
@@ -838,7 +833,7 @@ struct cmd_results *cmd_move(int argc, char **argv) {
838 return error; 833 return error;
839 } 834 }
840 if (!root->outputs->length) { 835 if (!root->outputs->length) {
841 return cmd_results_new(CMD_INVALID, "move", 836 return cmd_results_new(CMD_INVALID,
842 "Can't run this command while there's no outputs connected."); 837 "Can't run this command while there's no outputs connected.");
843 } 838 }
844 839
@@ -867,7 +862,7 @@ struct cmd_results *cmd_move(int argc, char **argv) {
867 } else if (strcasecmp(argv[0], "absolute") == 0) { 862 } else if (strcasecmp(argv[0], "absolute") == 0) {
868 return cmd_move_to_position(argc, argv); 863 return cmd_move_to_position(argc, argv);
869 } else { 864 } else {
870 return cmd_results_new(CMD_INVALID, "move", expected_syntax); 865 return cmd_results_new(CMD_INVALID, expected_syntax);
871 } 866 }
872 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 867 return cmd_results_new(CMD_SUCCESS, NULL);
873} 868}
diff --git a/sway/commands/no_focus.c b/sway/commands/no_focus.c
index cb81a445..07e824a1 100644
--- a/sway/commands/no_focus.c
+++ b/sway/commands/no_focus.c
@@ -13,7 +13,7 @@ struct cmd_results *cmd_no_focus(int argc, char **argv) {
13 char *err_str = NULL; 13 char *err_str = NULL;
14 struct criteria *criteria = criteria_parse(argv[0], &err_str); 14 struct criteria *criteria = criteria_parse(argv[0], &err_str);
15 if (!criteria) { 15 if (!criteria) {
16 error = cmd_results_new(CMD_INVALID, "no_focus", err_str); 16 error = cmd_results_new(CMD_INVALID, err_str);
17 free(err_str); 17 free(err_str);
18 return error; 18 return error;
19 } 19 }
@@ -21,5 +21,5 @@ struct cmd_results *cmd_no_focus(int argc, char **argv) {
21 criteria->type = CT_NO_FOCUS; 21 criteria->type = CT_NO_FOCUS;
22 list_add(config->criteria, criteria); 22 list_add(config->criteria, criteria);
23 23
24 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 24 return cmd_results_new(CMD_SUCCESS, NULL);
25} 25}
diff --git a/sway/commands/nop.c b/sway/commands/nop.c
index c12fe15a..973ade0e 100644
--- a/sway/commands/nop.c
+++ b/sway/commands/nop.c
@@ -1,5 +1,5 @@
1#include "sway/commands.h" 1#include "sway/commands.h"
2 2
3struct cmd_results *cmd_nop(int argc, char **argv) { 3struct cmd_results *cmd_nop(int argc, char **argv) {
4 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 4 return cmd_results_new(CMD_SUCCESS, NULL);
5} 5}
diff --git a/sway/commands/opacity.c b/sway/commands/opacity.c
index 8c45b528..14a07051 100644
--- a/sway/commands/opacity.c
+++ b/sway/commands/opacity.c
@@ -22,18 +22,18 @@ struct cmd_results *cmd_opacity(int argc, char **argv) {
22 struct sway_container *con = config->handler_context.container; 22 struct sway_container *con = config->handler_context.container;
23 23
24 if (con == NULL) { 24 if (con == NULL) {
25 return cmd_results_new(CMD_FAILURE, "opacity", "No current container"); 25 return cmd_results_new(CMD_FAILURE, "No current container");
26 } 26 }
27 27
28 float opacity = 0.0f; 28 float opacity = 0.0f;
29 29
30 if (!parse_opacity(argv[0], &opacity)) { 30 if (!parse_opacity(argv[0], &opacity)) {
31 return cmd_results_new(CMD_INVALID, "opacity <value>", 31 return cmd_results_new(CMD_INVALID,
32 "Invalid value (expected 0..1): %s", argv[0]); 32 "Invalid value (expected 0..1): %s", argv[0]);
33 } 33 }
34 34
35 con->alpha = opacity; 35 con->alpha = opacity;
36 container_damage_whole(con); 36 container_damage_whole(con);
37 37
38 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 38 return cmd_results_new(CMD_SUCCESS, NULL);
39} 39}
diff --git a/sway/commands/output.c b/sway/commands/output.c
index 00910843..73dbb723 100644
--- a/sway/commands/output.c
+++ b/sway/commands/output.c
@@ -43,7 +43,7 @@ struct cmd_results *cmd_output(int argc, char **argv) {
43 error = config_subcommand(argv, argc, output_handlers, 43 error = config_subcommand(argv, argc, output_handlers,
44 sizeof(output_handlers)); 44 sizeof(output_handlers));
45 } else { 45 } else {
46 error = cmd_results_new(CMD_INVALID, "output", 46 error = cmd_results_new(CMD_INVALID,
47 "Invalid output subcommand: %s.", *argv); 47 "Invalid output subcommand: %s.", *argv);
48 } 48 }
49 49
@@ -68,7 +68,7 @@ struct cmd_results *cmd_output(int argc, char **argv) {
68 apply_output_config_to_outputs(output); 68 apply_output_config_to_outputs(output);
69 } 69 }
70 70
71 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 71 return cmd_results_new(CMD_SUCCESS, NULL);
72 72
73fail: 73fail:
74 config->handler_context.output_config = NULL; 74 config->handler_context.output_config = NULL;
diff --git a/sway/commands/output/background.c b/sway/commands/output/background.c
index 2cd1b76a..ae2f0640 100644
--- a/sway/commands/output/background.c
+++ b/sway/commands/output/background.c
@@ -20,14 +20,14 @@ static const char *bg_options[] = {
20 20
21struct cmd_results *output_cmd_background(int argc, char **argv) { 21struct cmd_results *output_cmd_background(int argc, char **argv) {
22 if (!config->handler_context.output_config) { 22 if (!config->handler_context.output_config) {
23 return cmd_results_new(CMD_FAILURE, "output", "Missing output config"); 23 return cmd_results_new(CMD_FAILURE, "Missing output config");
24 } 24 }
25 if (!argc) { 25 if (!argc) {
26 return cmd_results_new(CMD_INVALID, "output", 26 return cmd_results_new(CMD_INVALID,
27 "Missing background file or color specification."); 27 "Missing background file or color specification.");
28 } 28 }
29 if (argc < 2) { 29 if (argc < 2) {
30 return cmd_results_new(CMD_INVALID, "output", 30 return cmd_results_new(CMD_INVALID,
31 "Missing background scaling mode or `solid_color`."); 31 "Missing background scaling mode or `solid_color`.");
32 } 32 }
33 33
@@ -57,7 +57,7 @@ struct cmd_results *output_cmd_background(int argc, char **argv) {
57 } 57 }
58 } 58 }
59 if (!valid) { 59 if (!valid) {
60 return cmd_results_new(CMD_INVALID, "output", 60 return cmd_results_new(CMD_INVALID,
61 "Missing background scaling mode."); 61 "Missing background scaling mode.");
62 } 62 }
63 63
@@ -70,7 +70,7 @@ struct cmd_results *output_cmd_background(int argc, char **argv) {
70 *ptr = '\\'; 70 *ptr = '\\';
71 } 71 }
72 if (wordexp(src, &p, 0) != 0 || p.we_wordv[0] == NULL) { 72 if (wordexp(src, &p, 0) != 0 || p.we_wordv[0] == NULL) {
73 struct cmd_results *cmd_res = cmd_results_new(CMD_INVALID, "output", 73 struct cmd_results *cmd_res = cmd_results_new(CMD_INVALID,
74 "Invalid syntax (%s)", src); 74 "Invalid syntax (%s)", src);
75 free(src); 75 free(src);
76 wordfree(&p); 76 wordfree(&p);
@@ -81,8 +81,7 @@ struct cmd_results *output_cmd_background(int argc, char **argv) {
81 wordfree(&p); 81 wordfree(&p);
82 if (!src) { 82 if (!src) {
83 wlr_log(WLR_ERROR, "Failed to duplicate string"); 83 wlr_log(WLR_ERROR, "Failed to duplicate string");
84 return cmd_results_new(CMD_FAILURE, "output", 84 return cmd_results_new(CMD_FAILURE, "Unable to allocate resource");
85 "Unable to allocate resource");
86 } 85 }
87 86
88 if (config->reading && *src != '/') { 87 if (config->reading && *src != '/') {
@@ -92,7 +91,7 @@ struct cmd_results *output_cmd_background(int argc, char **argv) {
92 if (!conf) { 91 if (!conf) {
93 wlr_log(WLR_ERROR, "Failed to duplicate string"); 92 wlr_log(WLR_ERROR, "Failed to duplicate string");
94 free(src); 93 free(src);
95 return cmd_results_new(CMD_FAILURE, "output", 94 return cmd_results_new(CMD_FAILURE,
96 "Unable to allocate resources"); 95 "Unable to allocate resources");
97 } 96 }
98 97
@@ -103,7 +102,7 @@ struct cmd_results *output_cmd_background(int argc, char **argv) {
103 free(rel_path); 102 free(rel_path);
104 free(conf); 103 free(conf);
105 wlr_log(WLR_ERROR, "Unable to allocate memory"); 104 wlr_log(WLR_ERROR, "Unable to allocate memory");
106 return cmd_results_new(CMD_FAILURE, "output", 105 return cmd_results_new(CMD_FAILURE,
107 "Unable to allocate resources"); 106 "Unable to allocate resources");
108 } 107 }
109 108
diff --git a/sway/commands/output/disable.c b/sway/commands/output/disable.c
index 65517c49..624f4056 100644
--- a/sway/commands/output/disable.c
+++ b/sway/commands/output/disable.c
@@ -3,7 +3,7 @@
3 3
4struct cmd_results *output_cmd_disable(int argc, char **argv) { 4struct cmd_results *output_cmd_disable(int argc, char **argv) {
5 if (!config->handler_context.output_config) { 5 if (!config->handler_context.output_config) {
6 return cmd_results_new(CMD_FAILURE, "output", "Missing output config"); 6 return cmd_results_new(CMD_FAILURE, "Missing output config");
7 } 7 }
8 config->handler_context.output_config->enabled = 0; 8 config->handler_context.output_config->enabled = 0;
9 9
diff --git a/sway/commands/output/dpms.c b/sway/commands/output/dpms.c
index 3492061e..9d75a80e 100644
--- a/sway/commands/output/dpms.c
+++ b/sway/commands/output/dpms.c
@@ -4,10 +4,10 @@
4 4
5struct cmd_results *output_cmd_dpms(int argc, char **argv) { 5struct cmd_results *output_cmd_dpms(int argc, char **argv) {
6 if (!config->handler_context.output_config) { 6 if (!config->handler_context.output_config) {
7 return cmd_results_new(CMD_FAILURE, "output", "Missing output config"); 7 return cmd_results_new(CMD_FAILURE, "Missing output config");
8 } 8 }
9 if (!argc) { 9 if (!argc) {
10 return cmd_results_new(CMD_INVALID, "output", "Missing dpms argument."); 10 return cmd_results_new(CMD_INVALID, "Missing dpms argument.");
11 } 11 }
12 12
13 if (parse_boolean(argv[0], true)) { 13 if (parse_boolean(argv[0], true)) {
diff --git a/sway/commands/output/enable.c b/sway/commands/output/enable.c
index 8e3314f8..71a7d75a 100644
--- a/sway/commands/output/enable.c
+++ b/sway/commands/output/enable.c
@@ -3,7 +3,7 @@
3 3
4struct cmd_results *output_cmd_enable(int argc, char **argv) { 4struct cmd_results *output_cmd_enable(int argc, char **argv) {
5 if (!config->handler_context.output_config) { 5 if (!config->handler_context.output_config) {
6 return cmd_results_new(CMD_FAILURE, "output", "Missing output config"); 6 return cmd_results_new(CMD_FAILURE, "Missing output config");
7 } 7 }
8 config->handler_context.output_config->enabled = 1; 8 config->handler_context.output_config->enabled = 1;
9 9
diff --git a/sway/commands/output/mode.c b/sway/commands/output/mode.c
index ef56ae9e..bcfce372 100644
--- a/sway/commands/output/mode.c
+++ b/sway/commands/output/mode.c
@@ -4,10 +4,10 @@
4 4
5struct cmd_results *output_cmd_mode(int argc, char **argv) { 5struct cmd_results *output_cmd_mode(int argc, char **argv) {
6 if (!config->handler_context.output_config) { 6 if (!config->handler_context.output_config) {
7 return cmd_results_new(CMD_FAILURE, "output", "Missing output config"); 7 return cmd_results_new(CMD_FAILURE, "Missing output config");
8 } 8 }
9 if (!argc) { 9 if (!argc) {
10 return cmd_results_new(CMD_INVALID, "output", "Missing mode argument."); 10 return cmd_results_new(CMD_INVALID, "Missing mode argument.");
11 } 11 }
12 12
13 struct output_config *output = config->handler_context.output_config; 13 struct output_config *output = config->handler_context.output_config;
@@ -17,20 +17,18 @@ struct cmd_results *output_cmd_mode(int argc, char **argv) {
17 if (*end) { 17 if (*end) {
18 // Format is 1234x4321 18 // Format is 1234x4321
19 if (*end != 'x') { 19 if (*end != 'x') {
20 return cmd_results_new(CMD_INVALID, "output", 20 return cmd_results_new(CMD_INVALID, "Invalid mode width.");
21 "Invalid mode width.");
22 } 21 }
23 ++end; 22 ++end;
24 output->height = strtol(end, &end, 10); 23 output->height = strtol(end, &end, 10);
25 if (*end) { 24 if (*end) {
26 if (*end != '@') { 25 if (*end != '@') {
27 return cmd_results_new(CMD_INVALID, "output", 26 return cmd_results_new(CMD_INVALID, "Invalid mode height.");
28 "Invalid mode height.");
29 } 27 }
30 ++end; 28 ++end;
31 output->refresh_rate = strtof(end, &end); 29 output->refresh_rate = strtof(end, &end);
32 if (strcasecmp("Hz", end) != 0) { 30 if (strcasecmp("Hz", end) != 0) {
33 return cmd_results_new(CMD_INVALID, "output", 31 return cmd_results_new(CMD_INVALID,
34 "Invalid mode refresh rate."); 32 "Invalid mode refresh rate.");
35 } 33 }
36 } 34 }
@@ -38,13 +36,12 @@ struct cmd_results *output_cmd_mode(int argc, char **argv) {
38 // Format is 1234 4321 36 // Format is 1234 4321
39 argc--; argv++; 37 argc--; argv++;
40 if (!argc) { 38 if (!argc) {
41 return cmd_results_new(CMD_INVALID, "output", 39 return cmd_results_new(CMD_INVALID,
42 "Missing mode argument (height)."); 40 "Missing mode argument (height).");
43 } 41 }
44 output->height = strtol(*argv, &end, 10); 42 output->height = strtol(*argv, &end, 10);
45 if (*end) { 43 if (*end) {
46 return cmd_results_new(CMD_INVALID, "output", 44 return cmd_results_new(CMD_INVALID, "Invalid mode height.");
47 "Invalid mode height.");
48 } 45 }
49 } 46 }
50 47
diff --git a/sway/commands/output/position.c b/sway/commands/output/position.c
index 449767b1..689462cb 100644
--- a/sway/commands/output/position.c
+++ b/sway/commands/output/position.c
@@ -4,11 +4,10 @@
4 4
5struct cmd_results *output_cmd_position(int argc, char **argv) { 5struct cmd_results *output_cmd_position(int argc, char **argv) {
6 if (!config->handler_context.output_config) { 6 if (!config->handler_context.output_config) {
7 return cmd_results_new(CMD_FAILURE, "output", "Missing output config"); 7 return cmd_results_new(CMD_FAILURE, "Missing output config");
8 } 8 }
9 if (!argc) { 9 if (!argc) {
10 return cmd_results_new(CMD_INVALID, "output", 10 return cmd_results_new(CMD_INVALID, "Missing position argument.");
11 "Missing position argument.");
12 } 11 }
13 12
14 char *end; 13 char *end;
@@ -16,26 +15,22 @@ struct cmd_results *output_cmd_position(int argc, char **argv) {
16 if (*end) { 15 if (*end) {
17 // Format is 1234,4321 16 // Format is 1234,4321
18 if (*end != ',') { 17 if (*end != ',') {
19 return cmd_results_new(CMD_INVALID, "output", 18 return cmd_results_new(CMD_INVALID, "Invalid position x.");
20 "Invalid position x.");
21 } 19 }
22 ++end; 20 ++end;
23 config->handler_context.output_config->y = strtol(end, &end, 10); 21 config->handler_context.output_config->y = strtol(end, &end, 10);
24 if (*end) { 22 if (*end) {
25 return cmd_results_new(CMD_INVALID, "output", 23 return cmd_results_new(CMD_INVALID, "Invalid position y.");
26 "Invalid position y.");
27 } 24 }
28 } else { 25 } else {
29 // Format is 1234 4321 (legacy) 26 // Format is 1234 4321 (legacy)
30 argc--; argv++; 27 argc--; argv++;
31 if (!argc) { 28 if (!argc) {
32 return cmd_results_new(CMD_INVALID, "output", 29 return cmd_results_new(CMD_INVALID, "Missing position argument (y).");
33 "Missing position argument (y).");
34 } 30 }
35 config->handler_context.output_config->y = strtol(*argv, &end, 10); 31 config->handler_context.output_config->y = strtol(*argv, &end, 10);
36 if (*end) { 32 if (*end) {
37 return cmd_results_new(CMD_INVALID, "output", 33 return cmd_results_new(CMD_INVALID, "Invalid position y.");
38 "Invalid position y.");
39 } 34 }
40 } 35 }
41 36
diff --git a/sway/commands/output/scale.c b/sway/commands/output/scale.c
index 0b4cc131..9398e06a 100644
--- a/sway/commands/output/scale.c
+++ b/sway/commands/output/scale.c
@@ -4,17 +4,16 @@
4 4
5struct cmd_results *output_cmd_scale(int argc, char **argv) { 5struct cmd_results *output_cmd_scale(int argc, char **argv) {
6 if (!config->handler_context.output_config) { 6 if (!config->handler_context.output_config) {
7 return cmd_results_new(CMD_FAILURE, "output", "Missing output config"); 7 return cmd_results_new(CMD_FAILURE, "Missing output config");
8 } 8 }
9 if (!argc) { 9 if (!argc) {
10 return cmd_results_new(CMD_INVALID, "output", 10 return cmd_results_new(CMD_INVALID, "Missing scale argument.");
11 "Missing scale argument.");
12 } 11 }
13 12
14 char *end; 13 char *end;
15 config->handler_context.output_config->scale = strtof(*argv, &end); 14 config->handler_context.output_config->scale = strtof(*argv, &end);
16 if (*end) { 15 if (*end) {
17 return cmd_results_new(CMD_INVALID, "output", "Invalid scale."); 16 return cmd_results_new(CMD_INVALID, "Invalid scale.");
18 } 17 }
19 18
20 config->handler_context.leftovers.argc = argc - 1; 19 config->handler_context.leftovers.argc = argc - 1;
diff --git a/sway/commands/output/transform.c b/sway/commands/output/transform.c
index ca6f73a4..8613a8e7 100644
--- a/sway/commands/output/transform.c
+++ b/sway/commands/output/transform.c
@@ -6,11 +6,10 @@
6 6
7struct cmd_results *output_cmd_transform(int argc, char **argv) { 7struct cmd_results *output_cmd_transform(int argc, char **argv) {
8 if (!config->handler_context.output_config) { 8 if (!config->handler_context.output_config) {
9 return cmd_results_new(CMD_FAILURE, "output", "Missing output config"); 9 return cmd_results_new(CMD_FAILURE, "Missing output config");
10 } 10 }
11 if (!argc) { 11 if (!argc) {
12 return cmd_results_new(CMD_INVALID, "output", 12 return cmd_results_new(CMD_INVALID, "Missing transform argument.");
13 "Missing transform argument.");
14 } 13 }
15 enum wl_output_transform transform; 14 enum wl_output_transform transform;
16 if (strcmp(*argv, "normal") == 0) { 15 if (strcmp(*argv, "normal") == 0) {
@@ -30,8 +29,7 @@ struct cmd_results *output_cmd_transform(int argc, char **argv) {
30 } else if (strcmp(*argv, "flipped-270") == 0) { 29 } else if (strcmp(*argv, "flipped-270") == 0) {
31 transform = WL_OUTPUT_TRANSFORM_FLIPPED_270; 30 transform = WL_OUTPUT_TRANSFORM_FLIPPED_270;
32 } else { 31 } else {
33 return cmd_results_new(CMD_INVALID, "output", 32 return cmd_results_new(CMD_INVALID, "Invalid output transform.");
34 "Invalid output transform.");
35 } 33 }
36 struct output_config *output = config->handler_context.output_config; 34 struct output_config *output = config->handler_context.output_config;
37 config->handler_context.leftovers.argc = argc - 1; 35 config->handler_context.leftovers.argc = argc - 1;
@@ -42,12 +40,12 @@ struct cmd_results *output_cmd_transform(int argc, char **argv) {
42 return NULL; 40 return NULL;
43 } 41 }
44 if (strcmp(output->name, "*") == 0) { 42 if (strcmp(output->name, "*") == 0) {
45 return cmd_results_new(CMD_INVALID, "output", 43 return cmd_results_new(CMD_INVALID,
46 "Cannot apply relative transform to all outputs."); 44 "Cannot apply relative transform to all outputs.");
47 } 45 }
48 struct sway_output *s_output = output_by_name_or_id(output->name); 46 struct sway_output *s_output = output_by_name_or_id(output->name);
49 if (s_output == NULL) { 47 if (s_output == NULL) {
50 return cmd_results_new(CMD_INVALID, "output", 48 return cmd_results_new(CMD_INVALID,
51 "Cannot apply relative transform to unknown output %s", output->name); 49 "Cannot apply relative transform to unknown output %s", output->name);
52 } 50 }
53 if (strcmp(argv[1], "anticlockwise") == 0) { 51 if (strcmp(argv[1], "anticlockwise") == 0) {
diff --git a/sway/commands/popup_during_fullscreen.c b/sway/commands/popup_during_fullscreen.c
index da1904b6..e8156262 100644
--- a/sway/commands/popup_during_fullscreen.c
+++ b/sway/commands/popup_during_fullscreen.c
@@ -16,10 +16,9 @@ struct cmd_results *cmd_popup_during_fullscreen(int argc, char **argv) {
16 } else if (strcasecmp(argv[0], "leave_fullscreen") == 0) { 16 } else if (strcasecmp(argv[0], "leave_fullscreen") == 0) {
17 config->popup_during_fullscreen = POPUP_LEAVE; 17 config->popup_during_fullscreen = POPUP_LEAVE;
18 } else { 18 } else {
19 return cmd_results_new(CMD_INVALID, "popup_during_fullscreen", 19 return cmd_results_new(CMD_INVALID, "Expected "
20 "Expected "
21 "'popup_during_fullscreen smart|ignore|leave_fullscreen'"); 20 "'popup_during_fullscreen smart|ignore|leave_fullscreen'");
22 } 21 }
23 22
24 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 23 return cmd_results_new(CMD_SUCCESS, NULL);
25} 24}
diff --git a/sway/commands/reload.c b/sway/commands/reload.c
index 3ccbbf34..6e7772e9 100644
--- a/sway/commands/reload.c
+++ b/sway/commands/reload.c
@@ -56,13 +56,12 @@ struct cmd_results *cmd_reload(int argc, char **argv) {
56 } 56 }
57 57
58 if (!load_main_config(config->current_config_path, true, true)) { 58 if (!load_main_config(config->current_config_path, true, true)) {
59 return cmd_results_new(CMD_FAILURE, "reload", 59 return cmd_results_new(CMD_FAILURE, "Error(s) reloading config.");
60 "Error(s) reloading config.");
61 } 60 }
62 61
63 // The reload command frees a lot of stuff, so to avoid use-after-frees 62 // The reload command frees a lot of stuff, so to avoid use-after-frees
64 // we schedule the reload to happen using an idle event. 63 // we schedule the reload to happen using an idle event.
65 wl_event_loop_add_idle(server.wl_event_loop, do_reload, NULL); 64 wl_event_loop_add_idle(server.wl_event_loop, do_reload, NULL);
66 65
67 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 66 return cmd_results_new(CMD_SUCCESS, NULL);
68} 67}
diff --git a/sway/commands/rename.c b/sway/commands/rename.c
index 491dbab0..a68302c4 100644
--- a/sway/commands/rename.c
+++ b/sway/commands/rename.c
@@ -10,7 +10,7 @@
10#include "sway/tree/container.h" 10#include "sway/tree/container.h"
11#include "sway/tree/workspace.h" 11#include "sway/tree/workspace.h"
12 12
13static const char* expected_syntax = 13static const char expected_syntax[] =
14 "Expected 'rename workspace <old_name> to <new_name>' or " 14 "Expected 'rename workspace <old_name> to <new_name>' or "
15 "'rename workspace to <new_name>'"; 15 "'rename workspace to <new_name>'";
16 16
@@ -20,11 +20,11 @@ struct cmd_results *cmd_rename(int argc, char **argv) {
20 return error; 20 return error;
21 } 21 }
22 if (!root->outputs->length) { 22 if (!root->outputs->length) {
23 return cmd_results_new(CMD_INVALID, "rename", 23 return cmd_results_new(CMD_INVALID,
24 "Can't run this command while there's no outputs connected."); 24 "Can't run this command while there's no outputs connected.");
25 } 25 }
26 if (strcasecmp(argv[0], "workspace") != 0) { 26 if (strcasecmp(argv[0], "workspace") != 0) {
27 return cmd_results_new(CMD_INVALID, "rename", expected_syntax); 27 return cmd_results_new(CMD_INVALID, expected_syntax);
28 } 28 }
29 29
30 int argn = 1; 30 int argn = 1;
@@ -36,7 +36,7 @@ struct cmd_results *cmd_rename(int argc, char **argv) {
36 } else if (strcasecmp(argv[1], "number") == 0) { 36 } else if (strcasecmp(argv[1], "number") == 0) {
37 // 'rename workspace number x to new_name' 37 // 'rename workspace number x to new_name'
38 if (!isdigit(argv[2][0])) { 38 if (!isdigit(argv[2][0])) {
39 return cmd_results_new(CMD_INVALID, "rename", 39 return cmd_results_new(CMD_INVALID,
40 "Invalid workspace number '%s'", argv[2]); 40 "Invalid workspace number '%s'", argv[2]);
41 } 41 }
42 workspace = workspace_by_number(argv[2]); 42 workspace = workspace_by_number(argv[2]);
@@ -56,14 +56,14 @@ struct cmd_results *cmd_rename(int argc, char **argv) {
56 } 56 }
57 57
58 if (!workspace) { 58 if (!workspace) {
59 return cmd_results_new(CMD_INVALID, "rename", 59 return cmd_results_new(CMD_INVALID,
60 "There is no workspace with that name"); 60 "There is no workspace with that name");
61 } 61 }
62 62
63 ++argn; // move past "to" 63 ++argn; // move past "to"
64 64
65 if (argn >= argc) { 65 if (argn >= argc) {
66 return cmd_results_new(CMD_INVALID, "rename", expected_syntax); 66 return cmd_results_new(CMD_INVALID, expected_syntax);
67 } 67 }
68 68
69 char *new_name = join_args(argv + argn, argc - argn); 69 char *new_name = join_args(argv + argn, argc - argn);
@@ -75,17 +75,16 @@ struct cmd_results *cmd_rename(int argc, char **argv) {
75 strcasecmp(new_name, "current") == 0 || 75 strcasecmp(new_name, "current") == 0 ||
76 strcasecmp(new_name, "number") == 0) { 76 strcasecmp(new_name, "number") == 0) {
77 free(new_name); 77 free(new_name);
78 return cmd_results_new(CMD_INVALID, "rename", 78 return cmd_results_new(CMD_INVALID,
79 "Cannot use special workspace name '%s'", argv[argn]); 79 "Cannot use special workspace name '%s'", argv[argn]);
80 } 80 }
81 struct sway_workspace *tmp_workspace = workspace_by_name(new_name); 81 struct sway_workspace *tmp_workspace = workspace_by_name(new_name);
82 if (tmp_workspace) { 82 if (tmp_workspace) {
83 free(new_name); 83 free(new_name);
84 if (tmp_workspace == workspace) { 84 if (tmp_workspace == workspace) {
85 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 85 return cmd_results_new(CMD_SUCCESS, NULL);
86 } else { 86 } else {
87 return cmd_results_new(CMD_INVALID, "rename", 87 return cmd_results_new(CMD_INVALID, "Workspace already exists");
88 "Workspace already exists");
89 } 88 }
90 } 89 }
91 90
@@ -96,5 +95,5 @@ struct cmd_results *cmd_rename(int argc, char **argv) {
96 output_sort_workspaces(workspace->output); 95 output_sort_workspaces(workspace->output);
97 ipc_event_workspace(NULL, workspace, "rename"); 96 ipc_event_workspace(NULL, workspace, "rename");
98 97
99 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 98 return cmd_results_new(CMD_SUCCESS, NULL);
100} 99}
diff --git a/sway/commands/resize.c b/sway/commands/resize.c
index 0e849afc..fad1ecb1 100644
--- a/sway/commands/resize.c
+++ b/sway/commands/resize.c
@@ -340,8 +340,7 @@ static struct cmd_results *resize_adjust_floating(uint32_t axis,
340 grow_x = -grow_width; 340 grow_x = -grow_width;
341 } 341 }
342 if (grow_x == 0 && grow_y == 0) { 342 if (grow_x == 0 && grow_y == 0) {
343 return cmd_results_new(CMD_INVALID, "resize", 343 return cmd_results_new(CMD_INVALID, "Cannot resize any further");
344 "Cannot resize any further");
345 } 344 }
346 con->x += grow_x; 345 con->x += grow_x;
347 con->y += grow_y; 346 con->y += grow_y;
@@ -355,7 +354,7 @@ static struct cmd_results *resize_adjust_floating(uint32_t axis,
355 354
356 arrange_container(con); 355 arrange_container(con);
357 356
358 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 357 return cmd_results_new(CMD_SUCCESS, NULL);
359} 358}
360 359
361/** 360/**
@@ -382,10 +381,9 @@ static struct cmd_results *resize_adjust_tiled(uint32_t axis,
382 double old_height = current->height; 381 double old_height = current->height;
383 resize_tiled(current, amount->amount, axis); 382 resize_tiled(current, amount->amount, axis);
384 if (current->width == old_width && current->height == old_height) { 383 if (current->width == old_width && current->height == old_height) {
385 return cmd_results_new(CMD_INVALID, "resize", 384 return cmd_results_new(CMD_INVALID, "Cannot resize any further");
386 "Cannot resize any further");
387 } 385 }
388 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 386 return cmd_results_new(CMD_SUCCESS, NULL);
389} 387}
390 388
391/** 389/**
@@ -433,7 +431,7 @@ static struct cmd_results *resize_set_tiled(struct sway_container *con,
433 } 431 }
434 } 432 }
435 433
436 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 434 return cmd_results_new(CMD_SUCCESS, NULL);
437} 435}
438 436
439/** 437/**
@@ -491,7 +489,7 @@ static struct cmd_results *resize_set_floating(struct sway_container *con,
491 489
492 arrange_container(con); 490 arrange_container(con);
493 491
494 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 492 return cmd_results_new(CMD_SUCCESS, NULL);
495} 493}
496 494
497/** 495/**
@@ -506,7 +504,7 @@ static struct cmd_results *cmd_resize_set(int argc, char **argv) {
506 if ((error = checkarg(argc, "resize", EXPECTED_AT_LEAST, 1))) { 504 if ((error = checkarg(argc, "resize", EXPECTED_AT_LEAST, 1))) {
507 return error; 505 return error;
508 } 506 }
509 const char *usage = "Expected 'resize set [width] <width> [px|ppt]' or " 507 const char usage[] = "Expected 'resize set [width] <width> [px|ppt]' or "
510 "'resize set height <height> [px|ppt]' or " 508 "'resize set height <height> [px|ppt]' or "
511 "'resize set [width] <width> [px|ppt] [height] <height> [px|ppt]'"; 509 "'resize set [width] <width> [px|ppt] [height] <height> [px|ppt]'";
512 510
@@ -520,7 +518,7 @@ static struct cmd_results *cmd_resize_set(int argc, char **argv) {
520 argc -= num_consumed_args; 518 argc -= num_consumed_args;
521 argv += num_consumed_args; 519 argv += num_consumed_args;
522 if (width.unit == RESIZE_UNIT_INVALID) { 520 if (width.unit == RESIZE_UNIT_INVALID) {
523 return cmd_results_new(CMD_INVALID, "resize set", usage); 521 return cmd_results_new(CMD_INVALID, usage);
524 } 522 }
525 } 523 }
526 524
@@ -534,7 +532,7 @@ static struct cmd_results *cmd_resize_set(int argc, char **argv) {
534 argc -= num_consumed_args; 532 argc -= num_consumed_args;
535 argv += num_consumed_args; 533 argv += num_consumed_args;
536 if (width.unit == RESIZE_UNIT_INVALID) { 534 if (width.unit == RESIZE_UNIT_INVALID) {
537 return cmd_results_new(CMD_INVALID, "resize set", usage); 535 return cmd_results_new(CMD_INVALID, usage);
538 } 536 }
539 } 537 }
540 538
@@ -562,11 +560,11 @@ static struct cmd_results *cmd_resize_set(int argc, char **argv) {
562 */ 560 */
563static struct cmd_results *cmd_resize_adjust(int argc, char **argv, 561static struct cmd_results *cmd_resize_adjust(int argc, char **argv,
564 int multiplier) { 562 int multiplier) {
565 const char *usage = "Expected 'resize grow|shrink <direction> " 563 const char usage[] = "Expected 'resize grow|shrink <direction> "
566 "[<amount> px|ppt [or <amount> px|ppt]]'"; 564 "[<amount> px|ppt [or <amount> px|ppt]]'";
567 uint32_t axis = parse_resize_axis(*argv); 565 uint32_t axis = parse_resize_axis(*argv);
568 if (axis == WLR_EDGE_NONE) { 566 if (axis == WLR_EDGE_NONE) {
569 return cmd_results_new(CMD_INVALID, "resize", usage); 567 return cmd_results_new(CMD_INVALID, usage);
570 } 568 }
571 --argc; ++argv; 569 --argc; ++argv;
572 570
@@ -577,7 +575,7 @@ static struct cmd_results *cmd_resize_adjust(int argc, char **argv,
577 argc -= num_consumed_args; 575 argc -= num_consumed_args;
578 argv += num_consumed_args; 576 argv += num_consumed_args;
579 if (first_amount.unit == RESIZE_UNIT_INVALID) { 577 if (first_amount.unit == RESIZE_UNIT_INVALID) {
580 return cmd_results_new(CMD_INVALID, "resize", usage); 578 return cmd_results_new(CMD_INVALID, usage);
581 } 579 }
582 } else { 580 } else {
583 first_amount.amount = 10; 581 first_amount.amount = 10;
@@ -587,7 +585,7 @@ static struct cmd_results *cmd_resize_adjust(int argc, char **argv,
587 // "or" 585 // "or"
588 if (argc) { 586 if (argc) {
589 if (strcmp(*argv, "or") != 0) { 587 if (strcmp(*argv, "or") != 0) {
590 return cmd_results_new(CMD_INVALID, "resize", usage); 588 return cmd_results_new(CMD_INVALID, usage);
591 } 589 }
592 --argc; ++argv; 590 --argc; ++argv;
593 } 591 }
@@ -599,7 +597,7 @@ static struct cmd_results *cmd_resize_adjust(int argc, char **argv,
599 argc -= num_consumed_args; 597 argc -= num_consumed_args;
600 argv += num_consumed_args; 598 argv += num_consumed_args;
601 if (second_amount.unit == RESIZE_UNIT_INVALID) { 599 if (second_amount.unit == RESIZE_UNIT_INVALID) {
602 return cmd_results_new(CMD_INVALID, "resize", usage); 600 return cmd_results_new(CMD_INVALID, usage);
603 } 601 }
604 } else { 602 } else {
605 second_amount.unit = RESIZE_UNIT_INVALID; 603 second_amount.unit = RESIZE_UNIT_INVALID;
@@ -621,7 +619,7 @@ static struct cmd_results *cmd_resize_adjust(int argc, char **argv,
621 } else if (second_amount.unit == RESIZE_UNIT_DEFAULT) { 619 } else if (second_amount.unit == RESIZE_UNIT_DEFAULT) {
622 return resize_adjust_floating(axis, &second_amount); 620 return resize_adjust_floating(axis, &second_amount);
623 } else { 621 } else {
624 return cmd_results_new(CMD_INVALID, "resize", 622 return cmd_results_new(CMD_INVALID,
625 "Floating containers cannot use ppt measurements"); 623 "Floating containers cannot use ppt measurements");
626 } 624 }
627 } 625 }
@@ -642,12 +640,12 @@ static struct cmd_results *cmd_resize_adjust(int argc, char **argv,
642 640
643struct cmd_results *cmd_resize(int argc, char **argv) { 641struct cmd_results *cmd_resize(int argc, char **argv) {
644 if (!root->outputs->length) { 642 if (!root->outputs->length) {
645 return cmd_results_new(CMD_INVALID, "resize", 643 return cmd_results_new(CMD_INVALID,
646 "Can't run this command while there's no outputs connected."); 644 "Can't run this command while there's no outputs connected.");
647 } 645 }
648 struct sway_container *current = config->handler_context.container; 646 struct sway_container *current = config->handler_context.container;
649 if (!current) { 647 if (!current) {
650 return cmd_results_new(CMD_INVALID, "resize", "Cannot resize nothing"); 648 return cmd_results_new(CMD_INVALID, "Cannot resize nothing");
651 } 649 }
652 650
653 struct cmd_results *error; 651 struct cmd_results *error;
@@ -665,8 +663,8 @@ struct cmd_results *cmd_resize(int argc, char **argv) {
665 return cmd_resize_adjust(argc - 1, &argv[1], -1); 663 return cmd_resize_adjust(argc - 1, &argv[1], -1);
666 } 664 }
667 665
668 const char *usage = "Expected 'resize <shrink|grow> " 666 const char usage[] = "Expected 'resize <shrink|grow> "
669 "<width|height|up|down|left|right> [<amount>] [px|ppt]'"; 667 "<width|height|up|down|left|right> [<amount>] [px|ppt]'";
670 668
671 return cmd_results_new(CMD_INVALID, "resize", usage); 669 return cmd_results_new(CMD_INVALID, usage);
672} 670}
diff --git a/sway/commands/scratchpad.c b/sway/commands/scratchpad.c
index 6eab456d..1162d51f 100644
--- a/sway/commands/scratchpad.c
+++ b/sway/commands/scratchpad.c
@@ -84,16 +84,14 @@ struct cmd_results *cmd_scratchpad(int argc, char **argv) {
84 return error; 84 return error;
85 } 85 }
86 if (strcmp(argv[0], "show") != 0) { 86 if (strcmp(argv[0], "show") != 0) {
87 return cmd_results_new(CMD_INVALID, "scratchpad", 87 return cmd_results_new(CMD_INVALID, "Expected 'scratchpad show'");
88 "Expected 'scratchpad show'");
89 } 88 }
90 if (!root->outputs->length) { 89 if (!root->outputs->length) {
91 return cmd_results_new(CMD_INVALID, "scratchpad", 90 return cmd_results_new(CMD_INVALID,
92 "Can't run this command while there's no outputs connected."); 91 "Can't run this command while there's no outputs connected.");
93 } 92 }
94 if (!root->scratchpad->length) { 93 if (!root->scratchpad->length) {
95 return cmd_results_new(CMD_INVALID, "scratchpad", 94 return cmd_results_new(CMD_INVALID, "Scratchpad is empty");
96 "Scratchpad is empty");
97 } 95 }
98 96
99 if (config->handler_context.using_criteria) { 97 if (config->handler_context.using_criteria) {
@@ -111,12 +109,12 @@ struct cmd_results *cmd_scratchpad(int argc, char **argv) {
111 // matches the criteria. If this container isn't in the scratchpad, 109 // matches the criteria. If this container isn't in the scratchpad,
112 // we'll just silently return a success. 110 // we'll just silently return a success.
113 if (!con->scratchpad) { 111 if (!con->scratchpad) {
114 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 112 return cmd_results_new(CMD_SUCCESS, NULL);
115 } 113 }
116 scratchpad_toggle_container(con); 114 scratchpad_toggle_container(con);
117 } else { 115 } else {
118 scratchpad_toggle_auto(); 116 scratchpad_toggle_auto();
119 } 117 }
120 118
121 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 119 return cmd_results_new(CMD_SUCCESS, NULL);
122} 120}
diff --git a/sway/commands/seat.c b/sway/commands/seat.c
index b8db862b..69000b57 100644
--- a/sway/commands/seat.c
+++ b/sway/commands/seat.c
@@ -21,8 +21,7 @@ struct cmd_results *cmd_seat(int argc, char **argv) {
21 21
22 config->handler_context.seat_config = new_seat_config(argv[0]); 22 config->handler_context.seat_config = new_seat_config(argv[0]);
23 if (!config->handler_context.seat_config) { 23 if (!config->handler_context.seat_config) {
24 return cmd_results_new(CMD_FAILURE, NULL, 24 return cmd_results_new(CMD_FAILURE, "Couldn't allocate config");
25 "Couldn't allocate config");
26 } 25 }
27 26
28 struct cmd_results *res = config_subcommand(argv + 1, argc - 1, 27 struct cmd_results *res = config_subcommand(argv + 1, argc - 1,
@@ -40,5 +39,5 @@ struct cmd_results *cmd_seat(int argc, char **argv) {
40 } 39 }
41 40
42 config->handler_context.seat_config = NULL; 41 config->handler_context.seat_config = NULL;
43 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 42 return cmd_results_new(CMD_SUCCESS, NULL);
44} 43}
diff --git a/sway/commands/seat/attach.c b/sway/commands/seat/attach.c
index 0fb17f1d..1e509a58 100644
--- a/sway/commands/seat/attach.c
+++ b/sway/commands/seat/attach.c
@@ -10,16 +10,16 @@ struct cmd_results *seat_cmd_attach(int argc, char **argv) {
10 return error; 10 return error;
11 } 11 }
12 if (!config->handler_context.seat_config) { 12 if (!config->handler_context.seat_config) {
13 return cmd_results_new(CMD_FAILURE, "attach", "No seat defined"); 13 return cmd_results_new(CMD_FAILURE, "No seat defined");
14 } 14 }
15 15
16 struct seat_attachment_config *attachment = seat_attachment_config_new(); 16 struct seat_attachment_config *attachment = seat_attachment_config_new();
17 if (!attachment) { 17 if (!attachment) {
18 return cmd_results_new(CMD_FAILURE, "attach", 18 return cmd_results_new(CMD_FAILURE,
19 "Failed to allocate seat attachment config"); 19 "Failed to allocate seat attachment config");
20 } 20 }
21 attachment->identifier = strdup(argv[0]); 21 attachment->identifier = strdup(argv[0]);
22 list_add(config->handler_context.seat_config->attachments, attachment); 22 list_add(config->handler_context.seat_config->attachments, attachment);
23 23
24 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 24 return cmd_results_new(CMD_SUCCESS, NULL);
25} 25}
diff --git a/sway/commands/seat/cursor.c b/sway/commands/seat/cursor.c
index 8d9e426a..4f805b22 100644
--- a/sway/commands/seat/cursor.c
+++ b/sway/commands/seat/cursor.c
@@ -10,7 +10,7 @@
10static struct cmd_results *press_or_release(struct sway_cursor *cursor, 10static struct cmd_results *press_or_release(struct sway_cursor *cursor,
11 char *action, char *button_str); 11 char *action, char *button_str);
12 12
13static const char *expected_syntax = "Expected 'cursor <move> <x> <y>' or " 13static const char expected_syntax[] = "Expected 'cursor <move> <x> <y>' or "
14 "'cursor <set> <x> <y>' or " 14 "'cursor <set> <x> <y>' or "
15 "'curor <press|release> <button[1-9]|event-name-or-code>'"; 15 "'curor <press|release> <button[1-9]|event-name-or-code>'";
16 16
@@ -18,7 +18,7 @@ static struct cmd_results *handle_command(struct sway_cursor *cursor,
18 int argc, char **argv) { 18 int argc, char **argv) {
19 if (strcasecmp(argv[0], "move") == 0) { 19 if (strcasecmp(argv[0], "move") == 0) {
20 if (argc < 3) { 20 if (argc < 3) {
21 return cmd_results_new(CMD_INVALID, "cursor", expected_syntax); 21 return cmd_results_new(CMD_INVALID, expected_syntax);
22 } 22 }
23 int delta_x = strtol(argv[1], NULL, 10); 23 int delta_x = strtol(argv[1], NULL, 10);
24 int delta_y = strtol(argv[2], NULL, 10); 24 int delta_y = strtol(argv[2], NULL, 10);
@@ -26,7 +26,7 @@ static struct cmd_results *handle_command(struct sway_cursor *cursor,
26 cursor_rebase(cursor); 26 cursor_rebase(cursor);
27 } else if (strcasecmp(argv[0], "set") == 0) { 27 } else if (strcasecmp(argv[0], "set") == 0) {
28 if (argc < 3) { 28 if (argc < 3) {
29 return cmd_results_new(CMD_INVALID, "cursor", expected_syntax); 29 return cmd_results_new(CMD_INVALID, expected_syntax);
30 } 30 }
31 // map absolute coords (0..1,0..1) to root container coords 31 // map absolute coords (0..1,0..1) to root container coords
32 float x = strtof(argv[1], NULL) / root->width; 32 float x = strtof(argv[1], NULL) / root->width;
@@ -35,7 +35,7 @@ static struct cmd_results *handle_command(struct sway_cursor *cursor,
35 cursor_rebase(cursor); 35 cursor_rebase(cursor);
36 } else { 36 } else {
37 if (argc < 2) { 37 if (argc < 2) {
38 return cmd_results_new(CMD_INVALID, "cursor", expected_syntax); 38 return cmd_results_new(CMD_INVALID, expected_syntax);
39 } 39 }
40 struct cmd_results *error = NULL; 40 struct cmd_results *error = NULL;
41 if ((error = press_or_release(cursor, argv[0], argv[1]))) { 41 if ((error = press_or_release(cursor, argv[0], argv[1]))) {
@@ -43,7 +43,7 @@ static struct cmd_results *handle_command(struct sway_cursor *cursor,
43 } 43 }
44 } 44 }
45 45
46 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 46 return cmd_results_new(CMD_SUCCESS, NULL);
47} 47}
48 48
49struct cmd_results *seat_cmd_cursor(int argc, char **argv) { 49struct cmd_results *seat_cmd_cursor(int argc, char **argv) {
@@ -53,18 +53,17 @@ struct cmd_results *seat_cmd_cursor(int argc, char **argv) {
53 } 53 }
54 struct seat_config *sc = config->handler_context.seat_config; 54 struct seat_config *sc = config->handler_context.seat_config;
55 if (!sc) { 55 if (!sc) {
56 return cmd_results_new(CMD_FAILURE, "cursor", "No seat defined"); 56 return cmd_results_new(CMD_FAILURE, "No seat defined");
57 } 57 }
58 58
59 if (config->reading || !config->active) { 59 if (config->reading || !config->active) {
60 return cmd_results_new(CMD_DEFER, NULL, NULL); 60 return cmd_results_new(CMD_DEFER, NULL);
61 } 61 }
62 62
63 if (strcmp(sc->name, "*") != 0) { 63 if (strcmp(sc->name, "*") != 0) {
64 struct sway_seat *seat = input_manager_get_seat(sc->name); 64 struct sway_seat *seat = input_manager_get_seat(sc->name);
65 if (!seat) { 65 if (!seat) {
66 return cmd_results_new(CMD_FAILURE, "cursor", 66 return cmd_results_new(CMD_FAILURE, "Failed to get seat");
67 "Failed to get seat");
68 } 67 }
69 error = handle_command(seat->cursor, argc, argv); 68 error = handle_command(seat->cursor, argc, argv);
70 } else { 69 } else {
@@ -77,7 +76,7 @@ struct cmd_results *seat_cmd_cursor(int argc, char **argv) {
77 } 76 }
78 } 77 }
79 78
80 return error ? error : cmd_results_new(CMD_SUCCESS, NULL, NULL); 79 return error ? error : cmd_results_new(CMD_SUCCESS, NULL);
81} 80}
82 81
83static struct cmd_results *press_or_release(struct sway_cursor *cursor, 82static struct cmd_results *press_or_release(struct sway_cursor *cursor,
@@ -89,14 +88,14 @@ static struct cmd_results *press_or_release(struct sway_cursor *cursor,
89 } else if (strcasecmp(action, "release") == 0) { 88 } else if (strcasecmp(action, "release") == 0) {
90 state = WLR_BUTTON_RELEASED; 89 state = WLR_BUTTON_RELEASED;
91 } else { 90 } else {
92 return cmd_results_new(CMD_INVALID, "cursor", expected_syntax); 91 return cmd_results_new(CMD_INVALID, expected_syntax);
93 } 92 }
94 93
95 char *message = NULL; 94 char *message = NULL;
96 button = get_mouse_button(button_str, &message); 95 button = get_mouse_button(button_str, &message);
97 if (message) { 96 if (message) {
98 struct cmd_results *error = 97 struct cmd_results *error =
99 cmd_results_new(CMD_INVALID, "cursor", message); 98 cmd_results_new(CMD_INVALID, message);
100 free(message); 99 free(message);
101 return error; 100 return error;
102 } else if (button == SWAY_SCROLL_UP || button == SWAY_SCROLL_DOWN 101 } else if (button == SWAY_SCROLL_UP || button == SWAY_SCROLL_DOWN
@@ -117,11 +116,10 @@ static struct cmd_results *press_or_release(struct sway_cursor *cursor,
117 .delta_discrete = delta 116 .delta_discrete = delta
118 }; 117 };
119 dispatch_cursor_axis(cursor, &event); 118 dispatch_cursor_axis(cursor, &event);
120 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 119 return cmd_results_new(CMD_SUCCESS, NULL);
121 } else if (!button) { 120 } else if (!button) {
122 return cmd_results_new(CMD_INVALID, "curor", 121 return cmd_results_new(CMD_INVALID, "Unknown button %s", button_str);
123 "Unknown button %s", button_str);
124 } 122 }
125 dispatch_cursor_button(cursor, NULL, 0, button, state); 123 dispatch_cursor_button(cursor, NULL, 0, button, state);
126 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 124 return cmd_results_new(CMD_SUCCESS, NULL);
127} 125}
diff --git a/sway/commands/seat/fallback.c b/sway/commands/seat/fallback.c
index 8f1ab12c..0330c353 100644
--- a/sway/commands/seat/fallback.c
+++ b/sway/commands/seat/fallback.c
@@ -8,11 +8,11 @@ struct cmd_results *seat_cmd_fallback(int argc, char **argv) {
8 return error; 8 return error;
9 } 9 }
10 if (!config->handler_context.seat_config) { 10 if (!config->handler_context.seat_config) {
11 return cmd_results_new(CMD_FAILURE, "fallback", "No seat defined"); 11 return cmd_results_new(CMD_FAILURE, "No seat defined");
12 } 12 }
13 13
14 config->handler_context.seat_config->fallback = 14 config->handler_context.seat_config->fallback =
15 parse_boolean(argv[0], false); 15 parse_boolean(argv[0], false);
16 16
17 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 17 return cmd_results_new(CMD_SUCCESS, NULL);
18} 18}
diff --git a/sway/commands/seat/hide_cursor.c b/sway/commands/seat/hide_cursor.c
index 343573b5..3bfce697 100644
--- a/sway/commands/seat/hide_cursor.c
+++ b/sway/commands/seat/hide_cursor.c
@@ -11,19 +11,18 @@ struct cmd_results *seat_cmd_hide_cursor(int argc, char **argv) {
11 return error; 11 return error;
12 } 12 }
13 if (!config->handler_context.seat_config) { 13 if (!config->handler_context.seat_config) {
14 return cmd_results_new(CMD_FAILURE, "hide_cursor", "No seat defined"); 14 return cmd_results_new(CMD_FAILURE, "No seat defined");
15 } 15 }
16 16
17 char *end; 17 char *end;
18 int timeout = strtol(argv[0], &end, 10); 18 int timeout = strtol(argv[0], &end, 10);
19 if (*end) { 19 if (*end) {
20 return cmd_results_new(CMD_INVALID, "hide_cursor", 20 return cmd_results_new(CMD_INVALID, "Expected an integer timeout");
21 "Expected an integer timeout");
22 } 21 }
23 if (timeout < 100 && timeout != 0) { 22 if (timeout < 100 && timeout != 0) {
24 timeout = 100; 23 timeout = 100;
25 } 24 }
26 config->handler_context.seat_config->hide_cursor_timeout = timeout; 25 config->handler_context.seat_config->hide_cursor_timeout = timeout;
27 26
28 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 27 return cmd_results_new(CMD_SUCCESS, NULL);
29} 28}
diff --git a/sway/commands/set.c b/sway/commands/set.c
index d912e4fd..c539e9fc 100644
--- a/sway/commands/set.c
+++ b/sway/commands/set.c
@@ -31,7 +31,7 @@ struct cmd_results *cmd_set(int argc, char **argv) {
31 } 31 }
32 32
33 if (argv[0][0] != '$') { 33 if (argv[0][0] != '$') {
34 return cmd_results_new(CMD_INVALID, "set", "variable '%s' must start with $", argv[0]); 34 return cmd_results_new(CMD_INVALID, "variable '%s' must start with $", argv[0]);
35 } 35 }
36 36
37 struct sway_variable *var = NULL; 37 struct sway_variable *var = NULL;
@@ -49,12 +49,12 @@ struct cmd_results *cmd_set(int argc, char **argv) {
49 } else { 49 } else {
50 var = malloc(sizeof(struct sway_variable)); 50 var = malloc(sizeof(struct sway_variable));
51 if (!var) { 51 if (!var) {
52 return cmd_results_new(CMD_FAILURE, "set", "Unable to allocate variable"); 52 return cmd_results_new(CMD_FAILURE, "Unable to allocate variable");
53 } 53 }
54 var->name = strdup(argv[0]); 54 var->name = strdup(argv[0]);
55 list_add(config->symbols, var); 55 list_add(config->symbols, var);
56 list_qsort(config->symbols, compare_set_qsort); 56 list_qsort(config->symbols, compare_set_qsort);
57 } 57 }
58 var->value = join_args(argv + 1, argc - 1); 58 var->value = join_args(argv + 1, argc - 1);
59 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 59 return cmd_results_new(CMD_SUCCESS, NULL);
60} 60}
diff --git a/sway/commands/show_marks.c b/sway/commands/show_marks.c
index 0baf6852..0d373b80 100644
--- a/sway/commands/show_marks.c
+++ b/sway/commands/show_marks.c
@@ -31,5 +31,5 @@ struct cmd_results *cmd_show_marks(int argc, char **argv) {
31 output_damage_whole(output); 31 output_damage_whole(output);
32 } 32 }
33 33
34 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 34 return cmd_results_new(CMD_SUCCESS, NULL);
35} 35}
diff --git a/sway/commands/smart_borders.c b/sway/commands/smart_borders.c
index fcb4040e..be346106 100644
--- a/sway/commands/smart_borders.c
+++ b/sway/commands/smart_borders.c
@@ -21,5 +21,5 @@ struct cmd_results *cmd_smart_borders(int argc, char **argv) {
21 21
22 arrange_root(); 22 arrange_root();
23 23
24 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 24 return cmd_results_new(CMD_SUCCESS, NULL);
25} 25}
diff --git a/sway/commands/smart_gaps.c b/sway/commands/smart_gaps.c
index f14b6760..b27f9ccd 100644
--- a/sway/commands/smart_gaps.c
+++ b/sway/commands/smart_gaps.c
@@ -19,5 +19,5 @@ struct cmd_results *cmd_smart_gaps(int argc, char **argv) {
19 19
20 arrange_root(); 20 arrange_root();
21 21
22 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 22 return cmd_results_new(CMD_SUCCESS, NULL);
23} 23}
diff --git a/sway/commands/split.c b/sway/commands/split.c
index 84385fa9..ed370d26 100644
--- a/sway/commands/split.c
+++ b/sway/commands/split.c
@@ -24,7 +24,7 @@ static struct cmd_results *do_split(int layout) {
24 24
25 arrange_workspace(ws); 25 arrange_workspace(ws);
26 26
27 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 27 return cmd_results_new(CMD_SUCCESS, NULL);
28} 28}
29 29
30struct cmd_results *cmd_split(int argc, char **argv) { 30struct cmd_results *cmd_split(int argc, char **argv) {
@@ -33,7 +33,7 @@ struct cmd_results *cmd_split(int argc, char **argv) {
33 return error; 33 return error;
34 } 34 }
35 if (!root->outputs->length) { 35 if (!root->outputs->length) {
36 return cmd_results_new(CMD_INVALID, "split", 36 return cmd_results_new(CMD_INVALID,
37 "Can't run this command while there's no outputs connected."); 37 "Can't run this command while there's no outputs connected.");
38 } 38 }
39 if (strcasecmp(argv[0], "v") == 0 || strcasecmp(argv[0], "vertical") == 0) { 39 if (strcasecmp(argv[0], "v") == 0 || strcasecmp(argv[0], "vertical") == 0) {
@@ -51,10 +51,10 @@ struct cmd_results *cmd_split(int argc, char **argv) {
51 return do_split(L_VERT); 51 return do_split(L_VERT);
52 } 52 }
53 } else { 53 } else {
54 return cmd_results_new(CMD_FAILURE, "split", 54 return cmd_results_new(CMD_FAILURE,
55 "Invalid split command (expected either horizontal or vertical)."); 55 "Invalid split command (expected either horizontal or vertical).");
56 } 56 }
57 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 57 return cmd_results_new(CMD_SUCCESS, NULL);
58} 58}
59 59
60struct cmd_results *cmd_splitv(int argc, char **argv) { 60struct cmd_results *cmd_splitv(int argc, char **argv) {
diff --git a/sway/commands/sticky.c b/sway/commands/sticky.c
index 7cd358a4..6cac8a45 100644
--- a/sway/commands/sticky.c
+++ b/sway/commands/sticky.c
@@ -19,11 +19,11 @@ struct cmd_results *cmd_sticky(int argc, char **argv) {
19 struct sway_container *container = config->handler_context.container; 19 struct sway_container *container = config->handler_context.container;
20 20
21 if (container == NULL) { 21 if (container == NULL) {
22 return cmd_results_new(CMD_FAILURE, "sticky", "No current container"); 22 return cmd_results_new(CMD_FAILURE, "No current container");
23 }; 23 };
24 24
25 if (!container_is_floating(container)) { 25 if (!container_is_floating(container)) {
26 return cmd_results_new(CMD_FAILURE, "sticky", 26 return cmd_results_new(CMD_FAILURE,
27 "Can't set sticky on a tiled container"); 27 "Can't set sticky on a tiled container");
28 } 28 }
29 29
@@ -43,5 +43,5 @@ struct cmd_results *cmd_sticky(int argc, char **argv) {
43 } 43 }
44 } 44 }
45 45
46 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 46 return cmd_results_new(CMD_SUCCESS, NULL);
47} 47}
diff --git a/sway/commands/swap.c b/sway/commands/swap.c
index 670d6bca..a8beb162 100644
--- a/sway/commands/swap.c
+++ b/sway/commands/swap.c
@@ -11,7 +11,7 @@
11#include "sway/tree/workspace.h" 11#include "sway/tree/workspace.h"
12#include "stringop.h" 12#include "stringop.h"
13 13
14static const char* EXPECTED_SYNTAX = 14static const char expected_syntax[] =
15 "Expected 'swap container with id|con_id|mark <arg>'"; 15 "Expected 'swap container with id|con_id|mark <arg>'";
16 16
17static void swap_places(struct sway_container *con1, 17static void swap_places(struct sway_container *con1,
@@ -171,12 +171,12 @@ struct cmd_results *cmd_swap(int argc, char **argv) {
171 return error; 171 return error;
172 } 172 }
173 if (!root->outputs->length) { 173 if (!root->outputs->length) {
174 return cmd_results_new(CMD_INVALID, "swap", 174 return cmd_results_new(CMD_INVALID,
175 "Can't run this command while there's no outputs connected."); 175 "Can't run this command while there's no outputs connected.");
176 } 176 }
177 177
178 if (strcasecmp(argv[0], "container") || strcasecmp(argv[1], "with")) { 178 if (strcasecmp(argv[0], "container") || strcasecmp(argv[1], "with")) {
179 return cmd_results_new(CMD_INVALID, "swap", EXPECTED_SYNTAX); 179 return cmd_results_new(CMD_INVALID, expected_syntax);
180 } 180 }
181 181
182 struct sway_container *current = config->handler_context.container; 182 struct sway_container *current = config->handler_context.container;
@@ -195,21 +195,21 @@ struct cmd_results *cmd_swap(int argc, char **argv) {
195 other = root_find_container(test_mark, value); 195 other = root_find_container(test_mark, value);
196 } else { 196 } else {
197 free(value); 197 free(value);
198 return cmd_results_new(CMD_INVALID, "swap", EXPECTED_SYNTAX); 198 return cmd_results_new(CMD_INVALID, expected_syntax);
199 } 199 }
200 200
201 if (!other) { 201 if (!other) {
202 error = cmd_results_new(CMD_FAILURE, "swap", 202 error = cmd_results_new(CMD_FAILURE,
203 "Failed to find %s '%s'", argv[2], value); 203 "Failed to find %s '%s'", argv[2], value);
204 } else if (!current) { 204 } else if (!current) {
205 error = cmd_results_new(CMD_FAILURE, "swap", 205 error = cmd_results_new(CMD_FAILURE,
206 "Can only swap with containers and views"); 206 "Can only swap with containers and views");
207 } else if (container_has_ancestor(current, other) 207 } else if (container_has_ancestor(current, other)
208 || container_has_ancestor(other, current)) { 208 || container_has_ancestor(other, current)) {
209 error = cmd_results_new(CMD_FAILURE, "swap", 209 error = cmd_results_new(CMD_FAILURE,
210 "Cannot swap ancestor and descendant"); 210 "Cannot swap ancestor and descendant");
211 } else if (container_is_floating(current) || container_is_floating(other)) { 211 } else if (container_is_floating(current) || container_is_floating(other)) {
212 error = cmd_results_new(CMD_FAILURE, "swap", 212 error = cmd_results_new(CMD_FAILURE,
213 "Swapping with floating containers is not supported"); 213 "Swapping with floating containers is not supported");
214 } 214 }
215 215
@@ -226,5 +226,5 @@ struct cmd_results *cmd_swap(int argc, char **argv) {
226 arrange_node(node_get_parent(&other->node)); 226 arrange_node(node_get_parent(&other->node));
227 } 227 }
228 228
229 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 229 return cmd_results_new(CMD_SUCCESS, NULL);
230} 230}
diff --git a/sway/commands/swaybg_command.c b/sway/commands/swaybg_command.c
index b184b193..91294bf4 100644
--- a/sway/commands/swaybg_command.c
+++ b/sway/commands/swaybg_command.c
@@ -21,5 +21,5 @@ struct cmd_results *cmd_swaybg_command(int argc, char **argv) {
21 free(new_command); 21 free(new_command);
22 } 22 }
23 23
24 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 24 return cmd_results_new(CMD_SUCCESS, NULL);
25} 25}
diff --git a/sway/commands/swaynag_command.c b/sway/commands/swaynag_command.c
index 5e54504c..b420f311 100644
--- a/sway/commands/swaynag_command.c
+++ b/sway/commands/swaynag_command.c
@@ -21,5 +21,5 @@ struct cmd_results *cmd_swaynag_command(int argc, char **argv) {
21 free(new_command); 21 free(new_command);
22 } 22 }
23 23
24 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 24 return cmd_results_new(CMD_SUCCESS, NULL);
25} 25}
diff --git a/sway/commands/tiling_drag.c b/sway/commands/tiling_drag.c
index 92fbde7c..e95526e8 100644
--- a/sway/commands/tiling_drag.c
+++ b/sway/commands/tiling_drag.c
@@ -9,5 +9,5 @@ struct cmd_results *cmd_tiling_drag(int argc, char **argv) {
9 9
10 config->tiling_drag = parse_boolean(argv[0], config->tiling_drag); 10 config->tiling_drag = parse_boolean(argv[0], config->tiling_drag);
11 11
12 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 12 return cmd_results_new(CMD_SUCCESS, NULL);
13} 13}
diff --git a/sway/commands/tiling_drag_threshold.c b/sway/commands/tiling_drag_threshold.c
index 6b0531c3..f1191118 100644
--- a/sway/commands/tiling_drag_threshold.c
+++ b/sway/commands/tiling_drag_threshold.c
@@ -12,11 +12,10 @@ struct cmd_results *cmd_tiling_drag_threshold(int argc, char **argv) {
12 char *inv; 12 char *inv;
13 int value = strtol(argv[0], &inv, 10); 13 int value = strtol(argv[0], &inv, 10);
14 if (*inv != '\0' || value < 0) { 14 if (*inv != '\0' || value < 0) {
15 return cmd_results_new(CMD_INVALID, "tiling_drag_threshold", 15 return cmd_results_new(CMD_INVALID, "Invalid threshold specified");
16 "Invalid threshold specified");
17 } 16 }
18 17
19 config->tiling_drag_threshold = value; 18 config->tiling_drag_threshold = value;
20 19
21 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 20 return cmd_results_new(CMD_SUCCESS, NULL);
22} 21}
diff --git a/sway/commands/title_align.c b/sway/commands/title_align.c
index 82578186..c30355de 100644
--- a/sway/commands/title_align.c
+++ b/sway/commands/title_align.c
@@ -17,7 +17,7 @@ struct cmd_results *cmd_title_align(int argc, char **argv) {
17 } else if (strcmp(argv[0], "right") == 0) { 17 } else if (strcmp(argv[0], "right") == 0) {
18 config->title_align = ALIGN_RIGHT; 18 config->title_align = ALIGN_RIGHT;
19 } else { 19 } else {
20 return cmd_results_new(CMD_INVALID, "title_align", 20 return cmd_results_new(CMD_INVALID,
21 "Expected 'title_align left|center|right'"); 21 "Expected 'title_align left|center|right'");
22 } 22 }
23 23
@@ -26,5 +26,5 @@ struct cmd_results *cmd_title_align(int argc, char **argv) {
26 output_damage_whole(output); 26 output_damage_whole(output);
27 } 27 }
28 28
29 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 29 return cmd_results_new(CMD_SUCCESS, NULL);
30} 30}
diff --git a/sway/commands/title_format.c b/sway/commands/title_format.c
index ef1c8935..9d312470 100644
--- a/sway/commands/title_format.c
+++ b/sway/commands/title_format.c
@@ -13,7 +13,7 @@ struct cmd_results *cmd_title_format(int argc, char **argv) {
13 } 13 }
14 struct sway_container *container = config->handler_context.container; 14 struct sway_container *container = config->handler_context.container;
15 if (!container || !container->view) { 15 if (!container || !container->view) {
16 return cmd_results_new(CMD_INVALID, "title_format", 16 return cmd_results_new(CMD_INVALID,
17 "Only views can have a title_format"); 17 "Only views can have a title_format");
18 } 18 }
19 struct sway_view *view = container->view; 19 struct sway_view *view = container->view;
@@ -24,5 +24,5 @@ struct cmd_results *cmd_title_format(int argc, char **argv) {
24 view->title_format = format; 24 view->title_format = format;
25 view_update_title(view, true); 25 view_update_title(view, true);
26 config_update_font_height(true); 26 config_update_font_height(true);
27 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 27 return cmd_results_new(CMD_SUCCESS, NULL);
28} 28}
diff --git a/sway/commands/titlebar_border_thickness.c b/sway/commands/titlebar_border_thickness.c
index c1e9bb52..3c5e9ba1 100644
--- a/sway/commands/titlebar_border_thickness.c
+++ b/sway/commands/titlebar_border_thickness.c
@@ -14,8 +14,7 @@ struct cmd_results *cmd_titlebar_border_thickness(int argc, char **argv) {
14 char *inv; 14 char *inv;
15 int value = strtol(argv[0], &inv, 10); 15 int value = strtol(argv[0], &inv, 10);
16 if (*inv != '\0' || value < 0 || value > config->titlebar_v_padding) { 16 if (*inv != '\0' || value < 0 || value > config->titlebar_v_padding) {
17 return cmd_results_new(CMD_FAILURE, "titlebar_border_thickness", 17 return cmd_results_new(CMD_FAILURE, "Invalid size specified");
18 "Invalid size specified");
19 } 18 }
20 19
21 config->titlebar_border_thickness = value; 20 config->titlebar_border_thickness = value;
@@ -26,5 +25,5 @@ struct cmd_results *cmd_titlebar_border_thickness(int argc, char **argv) {
26 output_damage_whole(output); 25 output_damage_whole(output);
27 } 26 }
28 27
29 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 28 return cmd_results_new(CMD_SUCCESS, NULL);
30} 29}
diff --git a/sway/commands/titlebar_padding.c b/sway/commands/titlebar_padding.c
index a642e945..29ce59ff 100644
--- a/sway/commands/titlebar_padding.c
+++ b/sway/commands/titlebar_padding.c
@@ -14,8 +14,7 @@ struct cmd_results *cmd_titlebar_padding(int argc, char **argv) {
14 char *inv; 14 char *inv;
15 int h_value = strtol(argv[0], &inv, 10); 15 int h_value = strtol(argv[0], &inv, 10);
16 if (*inv != '\0' || h_value < 0 || h_value < config->titlebar_border_thickness) { 16 if (*inv != '\0' || h_value < 0 || h_value < config->titlebar_border_thickness) {
17 return cmd_results_new(CMD_FAILURE, "titlebar_padding", 17 return cmd_results_new(CMD_FAILURE, "Invalid size specified");
18 "Invalid size specified");
19 } 18 }
20 19
21 int v_value; 20 int v_value;
@@ -24,8 +23,7 @@ struct cmd_results *cmd_titlebar_padding(int argc, char **argv) {
24 } else { 23 } else {
25 v_value = strtol(argv[1], &inv, 10); 24 v_value = strtol(argv[1], &inv, 10);
26 if (*inv != '\0' || v_value < 0 || v_value < config->titlebar_border_thickness) { 25 if (*inv != '\0' || v_value < 0 || v_value < config->titlebar_border_thickness) {
27 return cmd_results_new(CMD_FAILURE, "titlebar_padding", 26 return cmd_results_new(CMD_FAILURE, "Invalid size specified");
28 "Invalid size specified");
29 } 27 }
30 } 28 }
31 29
@@ -38,5 +36,5 @@ struct cmd_results *cmd_titlebar_padding(int argc, char **argv) {
38 output_damage_whole(output); 36 output_damage_whole(output);
39 } 37 }
40 38
41 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 39 return cmd_results_new(CMD_SUCCESS, NULL);
42} 40}
diff --git a/sway/commands/unmark.c b/sway/commands/unmark.c
index 98ac6ff2..cedfcfb2 100644
--- a/sway/commands/unmark.c
+++ b/sway/commands/unmark.c
@@ -49,5 +49,5 @@ struct cmd_results *cmd_unmark(int argc, char **argv) {
49 } 49 }
50 free(mark); 50 free(mark);
51 51
52 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 52 return cmd_results_new(CMD_SUCCESS, NULL);
53} 53}
diff --git a/sway/commands/urgent.c b/sway/commands/urgent.c
index 4f283c55..3a2b00ed 100644
--- a/sway/commands/urgent.c
+++ b/sway/commands/urgent.c
@@ -13,11 +13,10 @@ struct cmd_results *cmd_urgent(int argc, char **argv) {
13 } 13 }
14 struct sway_container *container = config->handler_context.container; 14 struct sway_container *container = config->handler_context.container;
15 if (!container) { 15 if (!container) {
16 return cmd_results_new(CMD_FAILURE, "urgent", "No current container"); 16 return cmd_results_new(CMD_FAILURE, "No current container");
17 } 17 }
18 if (!container->view) { 18 if (!container->view) {
19 return cmd_results_new(CMD_INVALID, "urgent", 19 return cmd_results_new(CMD_INVALID, "Only views can be urgent");
20 "Only views can be urgent");
21 } 20 }
22 struct sway_view *view = container->view; 21 struct sway_view *view = container->view;
23 22
@@ -29,5 +28,5 @@ struct cmd_results *cmd_urgent(int argc, char **argv) {
29 view_set_urgent(view, parse_boolean(argv[0], view_is_urgent(view))); 28 view_set_urgent(view, parse_boolean(argv[0], view_is_urgent(view)));
30 } 29 }
31 30
32 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 31 return cmd_results_new(CMD_SUCCESS, NULL);
33} 32}
diff --git a/sway/commands/workspace.c b/sway/commands/workspace.c
index 211b344d..6bfca506 100644
--- a/sway/commands/workspace.c
+++ b/sway/commands/workspace.c
@@ -58,7 +58,7 @@ static void prevent_invalid_outer_gaps(struct workspace_config *wsc) {
58 58
59static struct cmd_results *cmd_workspace_gaps(int argc, char **argv, 59static struct cmd_results *cmd_workspace_gaps(int argc, char **argv,
60 int gaps_location) { 60 int gaps_location) {
61 const char *expected = "Expected 'workspace <name> gaps " 61 const char expected[] = "Expected 'workspace <name> gaps "
62 "inner|outer|horizontal|vertical|top|right|bottom|left <px>'"; 62 "inner|outer|horizontal|vertical|top|right|bottom|left <px>'";
63 struct cmd_results *error = NULL; 63 struct cmd_results *error = NULL;
64 if ((error = checkarg(argc, "workspace", EXPECTED_EQUAL_TO, 64 if ((error = checkarg(argc, "workspace", EXPECTED_EQUAL_TO,
@@ -69,7 +69,7 @@ static struct cmd_results *cmd_workspace_gaps(int argc, char **argv,
69 struct workspace_config *wsc = workspace_config_find_or_create(ws_name); 69 struct workspace_config *wsc = workspace_config_find_or_create(ws_name);
70 free(ws_name); 70 free(ws_name);
71 if (!wsc) { 71 if (!wsc) {
72 return cmd_results_new(CMD_FAILURE, "workspace gaps", 72 return cmd_results_new(CMD_FAILURE,
73 "Unable to allocate workspace output"); 73 "Unable to allocate workspace output");
74 } 74 }
75 75
@@ -77,7 +77,7 @@ static struct cmd_results *cmd_workspace_gaps(int argc, char **argv,
77 int amount = strtol(argv[gaps_location + 2], &end, 10); 77 int amount = strtol(argv[gaps_location + 2], &end, 10);
78 if (strlen(end)) { 78 if (strlen(end)) {
79 free(end); 79 free(end);
80 return cmd_results_new(CMD_FAILURE, "workspace gaps", expected); 80 return cmd_results_new(CMD_FAILURE, expected);
81 } 81 }
82 82
83 bool valid = false; 83 bool valid = false;
@@ -108,7 +108,7 @@ static struct cmd_results *cmd_workspace_gaps(int argc, char **argv,
108 } 108 }
109 } 109 }
110 if (!valid) { 110 if (!valid) {
111 return cmd_results_new(CMD_INVALID, "workspace gaps", expected); 111 return cmd_results_new(CMD_INVALID, expected);
112 } 112 }
113 113
114 // Prevent invalid gaps configurations. 114 // Prevent invalid gaps configurations.
@@ -150,7 +150,7 @@ struct cmd_results *cmd_workspace(int argc, char **argv) {
150 struct workspace_config *wsc = workspace_config_find_or_create(ws_name); 150 struct workspace_config *wsc = workspace_config_find_or_create(ws_name);
151 free(ws_name); 151 free(ws_name);
152 if (!wsc) { 152 if (!wsc) {
153 return cmd_results_new(CMD_FAILURE, "workspace output", 153 return cmd_results_new(CMD_FAILURE,
154 "Unable to allocate workspace output"); 154 "Unable to allocate workspace output");
155 } 155 }
156 for (int i = output_location + 1; i < argc; ++i) { 156 for (int i = output_location + 1; i < argc; ++i) {
@@ -162,9 +162,9 @@ struct cmd_results *cmd_workspace(int argc, char **argv) {
162 } 162 }
163 } else { 163 } else {
164 if (config->reading || !config->active) { 164 if (config->reading || !config->active) {
165 return cmd_results_new(CMD_DEFER, "workspace", NULL); 165 return cmd_results_new(CMD_DEFER, NULL);
166 } else if (!root->outputs->length) { 166 } else if (!root->outputs->length) {
167 return cmd_results_new(CMD_INVALID, "workspace", 167 return cmd_results_new(CMD_INVALID,
168 "Can't run this command while there's no outputs connected."); 168 "Can't run this command while there's no outputs connected.");
169 } 169 }
170 170
@@ -181,11 +181,11 @@ struct cmd_results *cmd_workspace(int argc, char **argv) {
181 struct sway_workspace *ws = NULL; 181 struct sway_workspace *ws = NULL;
182 if (strcasecmp(argv[0], "number") == 0) { 182 if (strcasecmp(argv[0], "number") == 0) {
183 if (argc < 2) { 183 if (argc < 2) {
184 return cmd_results_new(CMD_INVALID, "workspace", 184 return cmd_results_new(CMD_INVALID,
185 "Expected workspace number"); 185 "Expected workspace number");
186 } 186 }
187 if (!isdigit(argv[1][0])) { 187 if (!isdigit(argv[1][0])) {
188 return cmd_results_new(CMD_INVALID, "workspace", 188 return cmd_results_new(CMD_INVALID,
189 "Invalid workspace number '%s'", argv[1]); 189 "Invalid workspace number '%s'", argv[1]);
190 } 190 }
191 if (!(ws = workspace_by_number(argv[1]))) { 191 if (!(ws = workspace_by_number(argv[1]))) {
@@ -202,7 +202,7 @@ struct cmd_results *cmd_workspace(int argc, char **argv) {
202 } else if (strcasecmp(argv[0], "back_and_forth") == 0) { 202 } else if (strcasecmp(argv[0], "back_and_forth") == 0) {
203 struct sway_seat *seat = config->handler_context.seat; 203 struct sway_seat *seat = config->handler_context.seat;
204 if (!seat->prev_workspace_name) { 204 if (!seat->prev_workspace_name) {
205 return cmd_results_new(CMD_INVALID, "workspace", 205 return cmd_results_new(CMD_INVALID,
206 "There is no previous workspace"); 206 "There is no previous workspace");
207 } 207 }
208 if (!(ws = workspace_by_name(argv[0]))) { 208 if (!(ws = workspace_by_name(argv[0]))) {
@@ -218,5 +218,5 @@ struct cmd_results *cmd_workspace(int argc, char **argv) {
218 workspace_switch(ws, no_auto_back_and_forth); 218 workspace_switch(ws, no_auto_back_and_forth);
219 seat_consider_warp_to_focus(config->handler_context.seat); 219 seat_consider_warp_to_focus(config->handler_context.seat);
220 } 220 }
221 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 221 return cmd_results_new(CMD_SUCCESS, NULL);
222} 222}
diff --git a/sway/commands/workspace_layout.c b/sway/commands/workspace_layout.c
index ed4c0ee0..4fed05ab 100644
--- a/sway/commands/workspace_layout.c
+++ b/sway/commands/workspace_layout.c
@@ -14,8 +14,8 @@ struct cmd_results *cmd_workspace_layout(int argc, char **argv) {
14 } else if (strcasecmp(argv[0], "tabbed") == 0) { 14 } else if (strcasecmp(argv[0], "tabbed") == 0) {
15 config->default_layout = L_TABBED; 15 config->default_layout = L_TABBED;
16 } else { 16 } else {
17 return cmd_results_new(CMD_INVALID, "workspace_layout", 17 return cmd_results_new(CMD_INVALID,
18 "Expected 'workspace_layout <default|stacking|tabbed>'"); 18 "Expected 'workspace_layout <default|stacking|tabbed>'");
19 } 19 }
20 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 20 return cmd_results_new(CMD_SUCCESS, NULL);
21} 21}
diff --git a/sway/commands/ws_auto_back_and_forth.c b/sway/commands/ws_auto_back_and_forth.c
index adb851c2..e4411c8e 100644
--- a/sway/commands/ws_auto_back_and_forth.c
+++ b/sway/commands/ws_auto_back_and_forth.c
@@ -10,5 +10,5 @@ struct cmd_results *cmd_ws_auto_back_and_forth(int argc, char **argv) {
10 } 10 }
11 config->auto_back_and_forth = 11 config->auto_back_and_forth =
12 parse_boolean(argv[0], config->auto_back_and_forth); 12 parse_boolean(argv[0], config->auto_back_and_forth);
13 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 13 return cmd_results_new(CMD_SUCCESS, NULL);
14} 14}
diff --git a/sway/commands/xwayland.c b/sway/commands/xwayland.c
index 03a0121b..c3f73f67 100644
--- a/sway/commands/xwayland.c
+++ b/sway/commands/xwayland.c
@@ -17,5 +17,5 @@ struct cmd_results *cmd_xwayland(int argc, char **argv) {
17 "sway hasn't been built with Xwayland support"); 17 "sway hasn't been built with Xwayland support");
18#endif 18#endif
19 19
20 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 20 return cmd_results_new(CMD_SUCCESS, NULL);
21} 21}