Drop wmenu -x option - wmenu - 🔧 fork of wmenu
 (HTM) git clone git@git.drkhsh.at/wmenu.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 6a39269d2e73273de324ed156eba71e5bdcd9602
 (DIR) parent e4c4627eebc57a6af5812c69f6dc3f9992d9c770
 (HTM) Author: adnano <me@adnano.co>
       Date:   Thu,  2 May 2024 14:44:09 -0400
       
       Drop wmenu -x option
       
       Diffstat:
         M README.md                           |       2 +-
         M docs/wmenu.1.scd                    |       5 +----
         M menu.c                              |      54 +------------------------------
         M menu.h                              |       2 --
         M wmenu_run                           |       2 +-
       
       5 files changed, 4 insertions(+), 61 deletions(-)
       ---
 (DIR) diff --git a/README.md b/README.md
       @@ -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
        ```
        
 (DIR) diff --git a/docs/wmenu.1.scd b/docs/wmenu.1.scd
       @@ -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
 (DIR) diff --git a/menu.c b/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);
 (DIR) diff --git a/menu.h b/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
 (DIR) diff --git a/wmenu_run b/wmenu_run
       @@ -32,4 +32,4 @@ path() {
                fi
        }
        
       -path | wmenu -x "$@"
       +path | wmenu "$@" | ${SHELL:-"/bin/sh"} &