summaryrefslogtreecommitdiffstats
path: root/sway/commands.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands.c')
-rw-r--r--sway/commands.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/sway/commands.c b/sway/commands.c
index 51de7a50..f716efa3 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -3,6 +3,7 @@
3#include <wlc/wlc.h> 3#include <wlc/wlc.h>
4#include <stdio.h> 4#include <stdio.h>
5#include <stdlib.h> 5#include <stdlib.h>
6#include <errno.h>
6#include <string.h> 7#include <string.h>
7#include <unistd.h> 8#include <unistd.h>
8#include <ctype.h> 9#include <ctype.h>
@@ -281,6 +282,44 @@ static bool cmd_focus_follows_mouse(struct sway_config *config, int argc, char *
281 return true; 282 return true;
282} 283}
283 284
285static bool cmd_gaps(struct sway_config *config, int argc, char **argv) {
286 if (!checkarg(argc, "gaps", EXPECTED_AT_LEAST, 1)) {
287 return false;
288 }
289
290 if (argc == 1) {
291 char *end;
292 int amount = (int)strtol(argv[0], &end, 10);
293 if (errno == ERANGE || amount == 0) {
294 errno = 0;
295 return false;
296 }
297 if (config->gaps_inner == 0) {
298 config->gaps_inner = amount;
299 }
300 if (config->gaps_outer == 0) {
301 config->gaps_outer = amount;
302 }
303 } else if (argc == 2) {
304 char *end;
305 int amount = (int)strtol(argv[1], &end, 10);
306 if (errno == ERANGE || amount == 0) {
307 errno = 0;
308 return false;
309 }
310 if (strcmp(argv[0], "inner") == 0) {
311 config->gaps_inner = amount;
312 } else if (strcmp(argv[0], "outer") == 0) {
313 config->gaps_outer = amount;
314 } else {
315 return false;
316 }
317 } else {
318 return false;
319 }
320 return true;
321}
322
284static bool cmd_kill(struct sway_config *config, int argc, char **argv) { 323static bool cmd_kill(struct sway_config *config, int argc, char **argv) {
285 swayc_t *view = get_focused_container(&root_container); 324 swayc_t *view = get_focused_container(&root_container);
286 wlc_view_close(view->handle); 325 wlc_view_close(view->handle);
@@ -484,6 +523,7 @@ static struct cmd_handler handlers[] = {
484 { "focus", cmd_focus }, 523 { "focus", cmd_focus },
485 { "focus_follows_mouse", cmd_focus_follows_mouse }, 524 { "focus_follows_mouse", cmd_focus_follows_mouse },
486 { "fullscreen", cmd_fullscreen }, 525 { "fullscreen", cmd_fullscreen },
526 { "gaps", cmd_gaps },
487 { "kill", cmd_kill }, 527 { "kill", cmd_kill },
488 { "layout", cmd_layout }, 528 { "layout", cmd_layout },
489 { "log_colors", cmd_log_colors }, 529 { "log_colors", cmd_log_colors },