diff options
Diffstat (limited to 'sway/commands.c')
-rw-r--r-- | sway/commands.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/sway/commands.c b/sway/commands.c index 423b576f..09ee91e8 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -368,26 +368,27 @@ static bool cmd_mode(int argc, char **argv) { | |||
368 | if (!checkarg(argc, "move", EXPECTED_AT_LEAST, 1)) { | 368 | if (!checkarg(argc, "move", EXPECTED_AT_LEAST, 1)) { |
369 | return false; | 369 | return false; |
370 | } | 370 | } |
371 | const char *mode_name = argv[0]; | 371 | bool mode_make = strcmp(argv[argc-1], "{") == 0; |
372 | const char *mode_name = join_args(argv, argc - mode_make); | ||
372 | struct sway_mode *mode = NULL; | 373 | struct sway_mode *mode = NULL; |
373 | // Find mode | 374 | // Find mode |
374 | int i, len = config->modes->length; | 375 | int i, len = config->modes->length; |
375 | for (i = 0; i < len; ++i) { | 376 | for (i = 0; i < len; ++i) { |
376 | struct sway_mode *find = config->modes->items[i]; | 377 | struct sway_mode *find = config->modes->items[i]; |
377 | if (strcasecmp(find->name, mode_name)==0) { | 378 | if (strcasecmp(find->name, mode_name) == 0) { |
378 | mode = find; | 379 | mode = find; |
379 | break; | 380 | break; |
380 | } | 381 | } |
381 | } | 382 | } |
382 | // Create mode if it doesnt exist | 383 | // Create mode if it doesnt exist |
383 | if (!mode && argc >= 2 && strncmp(argv[1],"{",1) == 0) { | 384 | if (!mode && mode_make) { |
384 | mode = malloc(sizeof*mode); | 385 | mode = malloc(sizeof*mode); |
385 | mode->name = strdup(mode_name); | 386 | mode->name = strdup(mode_name); |
386 | mode->bindings = create_list(); | 387 | mode->bindings = create_list(); |
387 | list_add(config->modes, mode); | 388 | list_add(config->modes, mode); |
388 | } | 389 | } |
389 | if (!mode) { | 390 | if (!mode) { |
390 | sway_log(L_ERROR, "Invalide mode `%s'", mode_name); | 391 | sway_log(L_ERROR, "Unknown mode `%s'", mode_name); |
391 | return false; | 392 | return false; |
392 | } | 393 | } |
393 | sway_log(L_DEBUG, "Switching to mode `%s'",mode->name); | 394 | sway_log(L_DEBUG, "Switching to mode `%s'",mode->name); |