aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sway/commands.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/sway/commands.c b/sway/commands.c
index c53b13c3..c621fa92 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -746,16 +746,12 @@ static struct cmd_results *cmd_mode(int argc, char **argv) {
746 if ((error = checkarg(argc, "mode", EXPECTED_AT_LEAST, 1))) { 746 if ((error = checkarg(argc, "mode", EXPECTED_AT_LEAST, 1))) {
747 return error; 747 return error;
748 } 748 }
749 char *mode_name = join_args(argv, argc); 749
750 int mode_len = strlen(mode_name); 750 const char *mode_name = argv[0];
751 bool mode_make = mode_name[mode_len-1] == '{'; 751 bool mode_make = (argc == 2 && strcmp(argv[1], "{") == 0);
752 if (mode_make) { 752 if (mode_make) {
753 if (!config->reading) 753 if (!config->reading)
754 return cmd_results_new(CMD_FAILURE, "mode", "Can only be used in config file."); 754 return cmd_results_new(CMD_FAILURE, "mode", "Can only be used in config file.");
755 // Trim trailing spaces
756 do {
757 mode_name[--mode_len] = 0;
758 } while(isspace(mode_name[mode_len-1]));
759 } 755 }
760 struct sway_mode *mode = NULL; 756 struct sway_mode *mode = NULL;
761 // Find mode 757 // Find mode
@@ -776,13 +772,11 @@ static struct cmd_results *cmd_mode(int argc, char **argv) {
776 } 772 }
777 if (!mode) { 773 if (!mode) {
778 error = cmd_results_new(CMD_INVALID, "mode", "Unknown mode `%s'", mode_name); 774 error = cmd_results_new(CMD_INVALID, "mode", "Unknown mode `%s'", mode_name);
779 free(mode_name);
780 return error; 775 return error;
781 } 776 }
782 if ((config->reading && mode_make) || (!config->reading && !mode_make)) { 777 if ((config->reading && mode_make) || (!config->reading && !mode_make)) {
783 sway_log(L_DEBUG, "Switching to mode `%s'",mode->name); 778 sway_log(L_DEBUG, "Switching to mode `%s'",mode->name);
784 } 779 }
785 free(mode_name);
786 // Set current mode 780 // Set current mode
787 config->current_mode = mode; 781 config->current_mode = mode;
788 if (!mode_make) { 782 if (!mode_make) {