0

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

1 Answers1

2

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.

  • 1
    Thank you! What would you suggest to do if I set a fixed width, but the tasklist is full? The new entries disappear in this case.. Is there a way to limit the width capacity of the wibar? –  Oct 14 '21 at 20:39
  • 1
    You can limit the number using a filter. Or you can use `wibox.container.constraint` to get finer grained control over the time. You could also use a grid if you fear you will run out of space. – Emmanuel Lepage Vallee Oct 14 '21 at 21:35
  • 1
    Thank you, it looks like you already put this in your original answer. What I meant is that I can't figure out how to use `wibox.container.constraint` in code. `widget = wibox.container.constraint(wibox.container.background, 'max', 50,100),` is this correct? –  Oct 14 '21 at 21:39
  • 1
    It can work that way, but it's better to wrap the whole widget template into another dept lever of `{}`, then use the constrains container properties rather than pass everything in the constructor. – Emmanuel Lepage Vallee Oct 14 '21 at 21:41
  • `wibox.container.constraint` behaviour is unstable. When the bar is full the tasks get randomly resized. What would be very nice is to have exactly the same code above, but switch to `wibox.layout.flex.horizontal` when the bar is full. Would this be possible? (Thank you for all of your help). –  Oct 15 '21 at 08:48