diff --git a/client/bemenu-run.c b/client/bemenu-run.c index a419de4..1659c09 100644 --- a/client/bemenu-run.c +++ b/client/bemenu-run.c @@ -154,7 +154,12 @@ launch(const struct client *client, const char *bin) static void item_cb(const struct client *client, struct bm_item *item) { - launch(client, bm_item_get_text(item)); + if (client->no_exec) { + const char *text = bm_item_get_text(item); + printf("%s\n", (text ? text : "")); + } else { + launch(client, bm_item_get_text(item)); + } } int diff --git a/client/common/common.c b/client/common/common.c index e88eb59..971f2cf 100644 --- a/client/common/common.c +++ b/client/common/common.c @@ -175,7 +175,8 @@ usage(FILE *out, const char *name) " -I, --index select item at index automatically.\n" " --scrollbar display scrollbar. (always, autohide)\n" " --ifne only display menu if there are items.\n" - " --fork always fork. (bemenu-run)\n\n" + " --fork always fork. (bemenu-run)\n" + " --no-exec do not execute command. (bemenu-run)\n\n" "Use BEMENU_BACKEND env variable to force backend:\n" " curses ncurses based terminal backend\n" @@ -228,6 +229,7 @@ do_getopt(struct client *client, int *argc, char **argv[]) { "scrollbar", required_argument, 0, 0x100 }, { "ifne", no_argument, 0, 0x115 }, { "fork", no_argument, 0, 0x116 }, + { "no-exec", no_argument, 0, 0x117 }, { "bottom", no_argument, 0, 'b' }, { "grab", no_argument, 0, 'f' }, @@ -296,6 +298,9 @@ do_getopt(struct client *client, int *argc, char **argv[]) case 0x116: client->force_fork = true; break; + case 0x117: + client->no_exec = true; + break; case 'b': client->bottom = true; diff --git a/client/common/common.h b/client/common/common.h index 70ecd5c..6644332 100644 --- a/client/common/common.h +++ b/client/common/common.h @@ -21,6 +21,7 @@ struct client { bool ifne; bool no_overlap; bool force_fork, fork; + bool no_exec; }; char* cstrcopy(const char *str, size_t size); diff --git a/man/bemenu.1 b/man/bemenu.1 index e3ecb18..5c6cf74 100644 --- a/man/bemenu.1 +++ b/man/bemenu.1 @@ -96,6 +96,11 @@ Only displays the menu when there are items. Always fork. (bemenu-run) By default terminal backends won't fork. +.TP +.B \-\-no\-exec +Do not execute command. (bemenu-run) +Instead of running the selected item, send to stdout. + .SS Backend-specific Options These options are only available on backends specified in the parentheses