Search code examples
awesome-wm

Is it possible to make tasklist automatically switch to different layout?


I am using the following code for my wibar tasklist:

    s.mytasklist = awful.widget.tasklist
    {
        screen   = s,
        filter   = awful.widget.tasklist.filter.allscreen,
        buttons  = tasklist_buttons,
        layout   = wibox.layout.fixed.horizontal(),
        
        widget_template =
        {
        {
            {
                {
                    id     = 'clienticon',
                    widget = awful.widget.clienticon,
                },
                margins = 0,
                widget  = wibox.container.margin,
            },
            {
                id     = 'text_role',
                widget = wibox.widget.textbox,
            },
            layout = wibox.layout.fixed.horizontal,
        },
        
        id              = 'background_role',
        forced_width    = 200,
        forced_height   = 60,
        widget = wibox.container.background,

        create_callback = function(self, c, index, objects)
            self:get_children_by_id('clienticon')[1].client = c
        end,
        },
    }

    s.mytasklist_onlyminimised = awful.widget.tasklist
    {
        screen   = s,
        filter   = awful.widget.tasklist.filter.minimizedcurrenttags,
        buttons  = tasklist_buttons,

        style    = {
        shape_border_width = 1,
        shape_border_color = '#333333',
        shape  = gears.shape.partially_rounded_rect,
        },
    }

Which makes the tasks on the tasklist have fixed width (as according to this answer)

My question is:

Is it possible to make the tasklist switch to wibox.layout.flex.horizontal when the tasklist is full of tasks?


Solution

  • While you could technically replace the tasklist from a client.connect_signal("tagged", function(c) if #c.screen.selected_tag:clients() >= some_number then <make_a_new_tasklist> end end) style code, that's pretty cheap and ugly.

    So I think this would require to contribute a patch upstream to expose the taglist/tasklist constructor arguments as properties. The awful.widget.layoutlist already do it, but not the tag/tasklists.