custom width - 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 268df9fa4fc2adb896b1c0a0f41b19727d0b5166
 (DIR) parent 0a38d45abba5b04775b000a8deafb141d230687b
 (HTM) Author: drkhsh <me@drkhsh.at>
       Date:   Sun, 15 Jun 2025 23:38:05 +0200
       
       custom width
       
       Diffstat:
         M docs/wmenu.1.scd                    |       4 ++++
         M menu.c                              |       7 +++++--
         M menu.h                              |       1 +
         M wayland.c                           |       6 +++++-
       
       4 files changed, 15 insertions(+), 3 deletions(-)
       ---
 (DIR) diff --git a/docs/wmenu.1.scd b/docs/wmenu.1.scd
       @@ -9,6 +9,7 @@ wmenu - dynamic menu for Wayland
        *wmenu* [-biPv] \
          [-f _font_] \
          [-l _lines_] \
       +  [-w _width_] \
          [-o _output_] \
          [-p _prompt_] \
          [-N _color_] [-n _color_] \
       @@ -49,6 +50,9 @@ $PATH and runs the result.
        *-l* _lines_
                wmenu lists items vertically, with the given number of lines.
        
       +*-w* _width_
       +        the width of the window will be constrained to this value.
       +
        *-o* _output_
                wmenu is displayed on the output with the given name.
        
 (DIR) diff --git a/menu.c b/menu.c
       @@ -85,11 +85,11 @@ static bool parse_color(const char *color, uint32_t *result) {
        // Parse menu options from command line arguments.
        void menu_getopts(struct menu *menu, int argc, char *argv[]) {
                const char *usage =
       -                "Usage: wmenu [-biPv] [-f font] [-l lines] [-o output] [-p prompt]\n"
       +                "Usage: wmenu [-biPv] [-f font] [-l lines] [-w width] [-o output] [-p prompt]\n"
                        "\t[-N color] [-n color] [-M color] [-m color] [-S color] [-s color]\n";
        
                int opt;
       -        while ((opt = getopt(argc, argv, "bhiPvf:l:o:p:N:n:M:m:S:s:")) != -1) {
       +        while ((opt = getopt(argc, argv, "bhiPvf:l:w:o:p:N:n:M:m:S:s:")) != -1) {
                        switch (opt) {
                        case 'b':
                                menu->bottom = true;
       @@ -109,6 +109,9 @@ void menu_getopts(struct menu *menu, int argc, char *argv[]) {
                        case 'l':
                                menu->lines = atoi(optarg);
                                break;
       +                case 'w':
       +                        menu->customwidth = atoi(optarg);
       +                        break;
                        case 'o':
                                menu->output_name = optarg;
                                break;
 (DIR) diff --git a/menu.h b/menu.h
       @@ -58,6 +58,7 @@ struct menu {
        
                int width;
                int height;
       +        int customwidth;
                int line_height;
                int padding;
                int inputw;
 (DIR) diff --git a/wayland.c b/wayland.c
       @@ -220,7 +220,11 @@ static void layer_surface_configure(void *data,
                        struct zwlr_layer_surface_v1 *surface,
                        uint32_t serial, uint32_t width, uint32_t height) {
                struct wl_context *context = data;
       -        context->menu->width = width;
       +        if (context->menu->customwidth > 0) {
       +                context->menu->width = context->menu->customwidth;
       +        } else {
       +                context->menu->width = width;
       +        }
                context->menu->height = height;
                zwlr_layer_surface_v1_ack_configure(surface, serial);
        }