Drop wmenu -x option
This commit is contained in:
parent
e4c4627eeb
commit
6a39269d2e
5 changed files with 4 additions and 61 deletions
|
@ -27,7 +27,7 @@ See wmenu(1)
|
|||
To use wmenu with Sway, you can add the following to your configuration file:
|
||||
|
||||
```
|
||||
set $menu wmenu_run
|
||||
set $menu dmenu_path | wmenu | xargs swaymsg exec --
|
||||
bindsym $mod+d exec $menu
|
||||
```
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ wmenu - dynamic menu for Wayland
|
|||
|
||||
# SYNOPSIS
|
||||
|
||||
*wmenu* [-biPvx] \
|
||||
*wmenu* [-biPv] \
|
||||
[-f _font_] \
|
||||
[-l _lines_] \
|
||||
[-o _output_] \
|
||||
|
@ -37,9 +37,6 @@ to those matching the tokens in the input.
|
|||
*-v*
|
||||
prints version information to stdout, then exits.
|
||||
|
||||
*-x*
|
||||
wmenu will execute the selected item.
|
||||
|
||||
*-f* _font_
|
||||
defines the font used. For more information, see
|
||||
https://docs.gtk.org/Pango/type_func.FontDescription.from_string.html
|
||||
|
|
54
menu.c
54
menu.c
|
@ -94,7 +94,7 @@ void menu_getopts(struct menu *menu, int argc, char *argv[]) {
|
|||
"\t[-N color] [-n color] [-M color] [-m color] [-S color] [-s color]\n";
|
||||
|
||||
int opt;
|
||||
while ((opt = getopt(argc, argv, "bhiPvxf:l:o:p:N:n:M:m:S:s:")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "bhiPvf:l:o:p:N:n:M:m:S:s:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'b':
|
||||
menu->bottom = true;
|
||||
|
@ -108,9 +108,6 @@ void menu_getopts(struct menu *menu, int argc, char *argv[]) {
|
|||
case 'v':
|
||||
puts("wmenu " VERSION);
|
||||
exit(EXIT_SUCCESS);
|
||||
case 'x':
|
||||
menu->exec = true;
|
||||
break;
|
||||
case 'f':
|
||||
menu->font = optarg;
|
||||
break;
|
||||
|
@ -413,53 +410,6 @@ static void movewordedge(struct menu *menu, int dir) {
|
|||
}
|
||||
}
|
||||
|
||||
// Information needed to execute an item.
|
||||
struct executable {
|
||||
struct menu *menu;
|
||||
char *name;
|
||||
};
|
||||
|
||||
// Executes an item with an activation token.
|
||||
static void execute(struct executable *exe, const char *token) {
|
||||
menu_destroy(exe->menu);
|
||||
|
||||
setenv("XDG_ACTIVATION_TOKEN", token, true);
|
||||
execlp(exe->name, exe->name, NULL);
|
||||
|
||||
// Handle execution failure
|
||||
fprintf(stderr, "Failed to execute selection: %s\n", strerror(errno));
|
||||
free(exe->name);
|
||||
free(exe);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
static void activation_token_done(void *data, struct xdg_activation_token_v1 *activation_token,
|
||||
const char *token) {
|
||||
struct executable *exe = data;
|
||||
xdg_activation_token_v1_destroy(activation_token);
|
||||
execute(exe, token);
|
||||
}
|
||||
|
||||
static const struct xdg_activation_token_v1_listener activation_token_listener = {
|
||||
.done = activation_token_done,
|
||||
};
|
||||
|
||||
// Executes the selected item.
|
||||
static void menu_exec(struct menu *menu) {
|
||||
if (!menu->sel) {
|
||||
return;
|
||||
}
|
||||
|
||||
struct executable *exe = calloc(1, sizeof(struct executable));
|
||||
exe->menu = menu;
|
||||
exe->name = strdup(menu->sel->text);
|
||||
|
||||
struct xdg_activation_token_v1 *activation_token = xdg_activation_v1_get_activation_token(menu->activation);
|
||||
xdg_activation_token_v1_set_surface(activation_token, menu->surface);
|
||||
xdg_activation_token_v1_add_listener(activation_token, &activation_token_listener, exe);
|
||||
xdg_activation_token_v1_commit(activation_token);
|
||||
}
|
||||
|
||||
// Handle a keypress.
|
||||
void menu_keypress(struct menu *menu, enum wl_keyboard_key_state key_state,
|
||||
xkb_keysym_t sym) {
|
||||
|
@ -639,8 +589,6 @@ void menu_keypress(struct menu *menu, enum wl_keyboard_key_state key_state,
|
|||
puts(menu->input);
|
||||
fflush(stdout);
|
||||
menu->exit = true;
|
||||
} else if (menu->exec) {
|
||||
menu_exec(menu);
|
||||
} else {
|
||||
char *text = menu->sel ? menu->sel->text : menu->input;
|
||||
puts(text);
|
||||
|
|
2
menu.h
2
menu.h
|
@ -56,8 +56,6 @@ struct menu {
|
|||
int (*strncmp)(const char *, const char *, size_t);
|
||||
// Whether the input is a password
|
||||
bool passwd;
|
||||
// Whether to execute the selected item
|
||||
bool exec;
|
||||
// The font used to display the menu
|
||||
char *font;
|
||||
// The number of lines to list items vertically
|
||||
|
|
|
@ -32,4 +32,4 @@ path() {
|
|||
fi
|
||||
}
|
||||
|
||||
path | wmenu -x "$@"
|
||||
path | wmenu "$@" | ${SHELL:-"/bin/sh"} &
|
||||
|
|
Loading…
Add table
Reference in a new issue