summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorJari Vetoniemi <mailroxas@gmail.com>2017-02-14 21:53:15 +0200
committerJari Vetoniemi <mailroxas@gmail.com>2017-02-14 21:53:15 +0200
commitd6261274cf0b3aa51ce8ea7418a79495b20ad558 (patch)
treee1dafea8235ae5eb8783f6c11e278f81cd3f758c /client
parent5d4b35ec68fce67eefba74c1e50cf35b795d8359 (diff)
downloadbemenu-d6261274cf0b3aa51ce8ea7418a79495b20ad558.tar.gz
bemenu-d6261274cf0b3aa51ce8ea7418a79495b20ad558.tar.bz2
bemenu-d6261274cf0b3aa51ce8ea7418a79495b20ad558.zip
bemenu: Add --ifne option
Diffstat (limited to 'client')
-rw-r--r--client/common/common.c10
-rw-r--r--client/common/common.h1
2 files changed, 10 insertions, 1 deletions
diff --git a/client/common/common.c b/client/common/common.c
index 35bc9e3..7782925 100644
--- a/client/common/common.c
+++ b/client/common/common.c
@@ -68,7 +68,8 @@ usage(FILE *out, const char *name)
" -p, --prompt defines the prompt text to be displayed.\n"
" -P, --prefix text to shown before highlighted item.\n"
" -I, --index select item at index automatically.\n"
- " --scrollbar display scrollbar. (always, autohide)\n\n"
+ " --scrollbar display scrollbar. (always, autohide)\n"
+ " --ifne only display menu if there are items.\n\n"
"Use BEMENU_BACKEND env variable to force backend:\n"
" curses ncurses based terminal backend\n"
@@ -117,6 +118,7 @@ parse_args(struct client *client, int *argc, char **argv[])
{ "index", required_argument, 0, 'I' },
{ "prefix", required_argument, 0, 'P' },
{ "scrollbar", required_argument, 0, 0x100 },
+ { "ifne", no_argument, 0, 0x115 },
{ "bottom", no_argument, 0, 'b' },
{ "grab", no_argument, 0, 'f' },
@@ -177,6 +179,9 @@ parse_args(struct client *client, int *argc, char **argv[])
case 0x100:
client->scrollbar = (!strcmp(optarg, "always") ? BM_SCROLLBAR_ALWAYS : (!strcmp(optarg, "autohide") ? BM_SCROLLBAR_AUTOHIDE : BM_SCROLLBAR_NONE));
break;
+ case 0x115:
+ client->ifne = true;
+ break;
case 'b':
client->bottom = true;
@@ -280,6 +285,9 @@ run_menu(const struct client *client, struct bm_menu *menu, void (*item_cb)(stru
bm_menu_set_highlighted_index(menu, client->selected);
bm_menu_grab_keyboard(menu, true);
+ if (client->ifne && !bm_menu_get_items(menu, NULL))
+ return BM_RUN_RESULT_CANCEL;
+
uint32_t unicode;
enum bm_key key;
enum bm_run_result status = BM_RUN_RESULT_RUNNING;
diff --git a/client/common/common.h b/client/common/common.h
index af03127..66587f2 100644
--- a/client/common/common.h
+++ b/client/common/common.h
@@ -16,6 +16,7 @@ struct client {
bool bottom;
bool grab;
bool wrap;
+ bool ifne;
};
void parse_args(struct client *client, int *argc, char **argv[]);