Search code examples
luawidgetdesktopwindow-managersawesome-wm

Awesome wm setting size for the tasklist item


I'm coding a custom vertical wibox that contains my tasklist, I want it to look like this: enter image description here

but instead of being fixed height, the tasklist items just take up all the available space. Here's the result: enter image description here

Here's my code so far:

function render_task_box(s)
    myotherbox[s] = awful.wibox({ position = "left", screen = s, ontop =
    true, width = 200 })

    mytasklist[s] = awful.widget.tasklist(
        s,
        awful.widget.tasklist.filter.currenttags,
        mytasklist.buttons,
        nil,
        nil,
        wibox.layout.flex.vertical())




    local middle_layout = wibox.layout.fixed.vertical()
    middle_layout:add(mytasklist[s])

    local layout = wibox.layout.align.vertical()
    layout:set_middle(middle_layout)

    myotherbox[s]:set_widget(layout)

end

So how do I get wanted result? (or at least set height of tasklist icon)

Update

Looked up some docs and tried this:

local l = wibox.layout.flex.vertical();
l:set_max_widget_size(20)

It did nothing.


Solution

  • After reading some of the awesome's source code I've found a solution.

    Somewhere in your script require this

    local common = require("awful.widget.common")
    

    Then create a function that overrides task update function:

    function list_update(w, buttons, label, data, objects)
        -- call default widget drawing function
        common.list_update(w, buttons, label, data, objects)
        -- set widget size
        w:set_max_widget_size(20)
    end
    

    Then pass this function to tasklist

        mytasklist[s] = awful.widget.tasklist(s,
        awful.widget.tasklist.filter.currenttags,
        mytasklist.buttons,
        nil,
        list_update,
        wibox.layout.flex.vertical())
    

    Thats it!