diff options
author | Drew DeVault <sir@cmpwn.com> | 2015-08-09 12:26:32 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2015-08-09 12:26:32 -0400 |
commit | ea9659f39cb6211548e9ac892f327b9ba08b751a (patch) | |
tree | 423081c921b8e2e11b6fc39255adfee3c561bd37 /sway/commands.c | |
parent | bab080cea3d28dad387760d93db55cc711980d9a (diff) |
Implement exec
Diffstat (limited to 'sway/commands.c')
-rw-r--r-- | sway/commands.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/sway/commands.c b/sway/commands.c index 8e6d19ec..6d8cd468 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -4,6 +4,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <unistd.h> #include <ctype.h> #include "stringop.h" #include "log.h" @@ -70,6 +71,20 @@ int cmd_bindsym(struct sway_config *config, int argc, char **argv) { return 0; } +int cmd_exec(struct sway_config *config, int argc, char **argv) { + if (argc < 1) { + sway_log(L_ERROR, "Invalid exit command (expected 1 arguments, got %d)", argc); + return 1; + } + if (fork() == 0) { + char *args = join_args(argv, argc); + execl("/bin/sh", "sh", "-c", args, (char *)NULL); + free(args); + exit(0); + } + return 0; +} + int cmd_exit(struct sway_config *config, int argc, char **argv) { if (argc != 0) { sway_log(L_ERROR, "Invalid exit command (expected 1 arguments, got %d)", argc); @@ -80,7 +95,6 @@ int cmd_exit(struct sway_config *config, int argc, char **argv) { return 0; } - int cmd_focus_follows_mouse(struct sway_config *config, int argc, char **argv) { if (argc != 1) { sway_log(L_ERROR, "Invalid focus_follows_mouse command (expected 1 arguments, got %d)", argc); @@ -108,6 +122,7 @@ int cmd_set(struct sway_config *config, int argc, char **argv) { /* Keep alphabetized */ struct cmd_handler handlers[] = { { "bindsym", cmd_bindsym }, + { "exec", cmd_exec }, { "exit", cmd_exit }, { "focus_follows_mouse", cmd_focus_follows_mouse }, { "set", cmd_set }, |