Search code examples
awesome-wm

How to limit the width of window entries on the Wibar?


Right now if I open only a window, it fills all of the wibar completely. Until I open another window, now each takes half of the space.

Is there a way to set a static width that a single window can take on the wibar?

This is an example:

enter image description here


Solution

  • There is several ways to do this. I will list some of them and the pros/cons

    By default, the awful.widget.tasklist widget uses wibox.layout.flex.horizontal, which distribute the width. You want to replace it by wibox.layout.fixed.horizontal, which defaults to the widget preferred size. You also want to add a forced_width if you want the width to always be the same.

    enter image description here

        -- Create a tasklist widget
        s.mytasklist = awful.widget.tasklist {
            screen  = s,
            filter  = awful.widget.tasklist.filter.currenttags,
            layout  = wibox.layout.fixed.horizontal(),
            widget_template = {
                {
                    {
                        {
                            {
                                widget = awful.widget.clienticon,
                            },
                            margins = 2,
                            widget  = wibox.container.margin,
                        },
                        {
                            id     = "text_role",
                            widget = wibox.widget.textbox,
                        },
                        layout = wibox.layout.fixed.horizontal,
                    },
                    left  = 10,
                    right = 10,
                    widget = wibox.container.margin
                },
                forced_width = 100,
                id     = "background_role",
                widget = wibox.container.background,
            },
            buttons = tasklist_buttons
        }
    

    But you might also want to wrap this in a wibox.container.constraint container. This gives you the ability to set a minimum/maximum size rather than hardcode the value.