Add no-exec option to bemenu-run

This commit is contained in:
Corey Hinshaw 2020-02-22 10:35:47 -05:00 committed by Jari Vetoniemi
parent 15f96d2d23
commit 42ba51857d
4 changed files with 18 additions and 2 deletions

View File

@ -154,7 +154,12 @@ launch(const struct client *client, const char *bin)
static void static void
item_cb(const struct client *client, struct bm_item *item) item_cb(const struct client *client, struct bm_item *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)); launch(client, bm_item_get_text(item));
}
} }
int int

View File

@ -175,7 +175,8 @@ usage(FILE *out, const char *name)
" -I, --index select item at index automatically.\n" " -I, --index select item at index automatically.\n"
" --scrollbar display scrollbar. (always, autohide)\n" " --scrollbar display scrollbar. (always, autohide)\n"
" --ifne only display menu if there are items.\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" "Use BEMENU_BACKEND env variable to force backend:\n"
" curses ncurses based terminal 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 }, { "scrollbar", required_argument, 0, 0x100 },
{ "ifne", no_argument, 0, 0x115 }, { "ifne", no_argument, 0, 0x115 },
{ "fork", no_argument, 0, 0x116 }, { "fork", no_argument, 0, 0x116 },
{ "no-exec", no_argument, 0, 0x117 },
{ "bottom", no_argument, 0, 'b' }, { "bottom", no_argument, 0, 'b' },
{ "grab", no_argument, 0, 'f' }, { "grab", no_argument, 0, 'f' },
@ -296,6 +298,9 @@ do_getopt(struct client *client, int *argc, char **argv[])
case 0x116: case 0x116:
client->force_fork = true; client->force_fork = true;
break; break;
case 0x117:
client->no_exec = true;
break;
case 'b': case 'b':
client->bottom = true; client->bottom = true;

View File

@ -21,6 +21,7 @@ struct client {
bool ifne; bool ifne;
bool no_overlap; bool no_overlap;
bool force_fork, fork; bool force_fork, fork;
bool no_exec;
}; };
char* cstrcopy(const char *str, size_t size); char* cstrcopy(const char *str, size_t size);

View File

@ -96,6 +96,11 @@ Only displays the menu when there are items.
Always fork. (bemenu-run) Always fork. (bemenu-run)
By default terminal backends won't fork. 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 .SS Backend-specific Options
These options are only available on backends specified in the parentheses These options are only available on backends specified in the parentheses