gpt4 book ai didi

lua - 任务列表项的很棒的 wm 设置大小

转载 作者:行者123 更新时间:2023-12-02 01:35:49 26 4
gpt4 key购买 nike

我正在编写一个包含我的任务列表的自定义垂直 wibox,我希望它看起来像这样:
enter image description here

但不是固定高度,任务列表项目只是占用所有可用空间。结果如下:
enter image description here

到目前为止,这是我的代码:

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

那么我如何得到想要的结果呢? (或至少设置任务列表图标的高度)

更新

查了一些 docs并尝试了这个:
local l = wibox.layout.flex.vertical();
l:set_max_widget_size(20)

它什么也没做。

最佳答案

在阅读了一些很棒的源代码后,我找到了一个解决方案。

脚本中的某个地方需要这个

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

然后创建一个覆盖任务更新函数的函数:
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

然后将此函数传递给任务列表
    mytasklist[s] = awful.widget.tasklist(s,
awful.widget.tasklist.filter.currenttags,
mytasklist.buttons,
nil,
list_update,
wibox.layout.flex.vertical())

就是这样!

关于lua - 任务列表项的很棒的 wm 设置大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31293571/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com