summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmdtree.c5
-rw-r--r--command.c11
-rw-r--r--command.h3
3 files changed, 15 insertions, 4 deletions
diff --git a/cmdtree.c b/cmdtree.c
index 68e8a02..07720a8 100644
--- a/cmdtree.c
+++ b/cmdtree.c
@@ -292,8 +292,9 @@ run(Drw *drw) {
rootcmds = cmd->children;
draw_tree(drw, 0, 0, mw, mh);
}
- else // TODO: launch command
- done = 1;
+ else {
+ command_exec(cmd);
+ }
}
break;
diff --git a/command.c b/command.c
index accf212..ee31b05 100644
--- a/command.c
+++ b/command.c
@@ -4,6 +4,8 @@
#include "ccan/tal/tal.h"
#include "ccan/tal/str/str.h"
#include "ccan/str/str.h"
+#include <err.h>
+#include <unistd.h>
#include "util.h"
@@ -18,6 +20,11 @@ command_is_prefix(struct command *cmd) {
return count > 0;
}
+void
+command_exec(struct command *cmd) {
+ execlp(cmd->name, cmd->name, (char *)NULL);
+ err(1, "executing command %s", cmd->name);
+}
struct command *
command_lookup(struct command *cmd, const char *binding) {
@@ -33,7 +40,7 @@ command_lookup(struct command *cmd, const char *binding) {
static const struct command examples[] = {
{ .bind = "f", .name = "firefox" },
{ .bind = "m", .name = "misc" },
- { .bind = "e", .name = "spacemacs" },
+ { .bind = "e", .name = "emacs" },
{ .bind = "N", .name = "networking" },
};
@@ -57,7 +64,7 @@ test_root_commands(tal_t *ctx) {
}
child = cmds[i].children = tal_arr(cmds, struct command, i % 2);
for (j = 0; j < tal_count(child); j++) {
- child[j].name = tal_fmt(child, "child-%d-%d", (int)i, (int)j);
+ child[j].name = "sayhi";
child[j].bind = tal_fmt(child, "%c", (int)(c+j));
child[j].children = NULL;
}
diff --git a/command.h b/command.h
index 750f109..770d3a7 100644
--- a/command.h
+++ b/command.h
@@ -15,6 +15,9 @@ struct command {
void
command_init(struct command *cmd);
+void
+command_exec(struct command *cmd);
+
struct command *
command_lookup(struct command *cmd, const char *binding);