在迁移到 Awesome 3.5.1 之前,我的屏幕顶部有两个面板(在彼此的顶部,有点),底部没有。我用来实现这个 pre-3.5.* 的代码如下:
-- Create the wibox
mywibox[s] = awful.wibox({ position = "top", height = "32", screen = s })
-- Add widgets to the wibox - order matters
mywibox[s].widgets = {
{
{
-- Upper left section
mylauncher,
mytaglist[s],
mypromptbox[s],
-- My custom widgets, separators etc...
layout = awful.widget.layout.horizontal.leftright
},
{
-- Upper right section
mylayoutbox[s],
mytextclock,
-- More widgets, separators, etc...
s == 1 and mysystray or nil,
layout = awful.widget.layout.horizontal.rightleft
},
},
{
-- Lower section (only the tasklist)
mytasklist[s],
},
layout = awful.widget.layout.vertical.flex,
height = mywibox[s].height
}
现在我很难弄清楚如何使用 3.5 配置实现相同的目标。目前,我在顶部使用非常基本的一个面板(包含大部分小部件),在底部使用一个面板(包含任务列表)。代码如下:
-- Create the wibox
mywibox[s] = awful.wibox({ position = "top", height = "18", screen = s })
mywibox2[s] = awful.wibox({ position = "bottom", height = "18", screen = s })
-- Widgets that are aligned to the left
local left_layout = wibox.layout.fixed.horizontal()
left_layout:add(mylauncher)
left_layout:add(mytaglist[s])
left_layout:add(mypromptbox[s])
-- My custom widgets, separators, etc...
-- Widgets that are aligned to the right
local right_layout = wibox.layout.fixed.horizontal()
if s == 1 then right_layout:add(wibox.widget.systray()) end
-- My custom widgets, separators, etc...
right_layout:add(mytextclock)
right_layout:add(mylayoutbox[s])
-- Now bring it all together
local layout = wibox.layout.align.horizontal()
layout:set_left(left_layout)
layout:set_right(right_layout)
local layout2 = wibox.layout.align.horizontal()
layout2:set_middle(mytasklist[s])
mywibox[s]:set_widget(layout)
mywibox2[s]:set_widget(layout2)
如果有人知道如何编辑我当前的 rc.lua 以使其像上面的代码在 Awesome 3.4.* 中那样工作,那将不胜感激。
最佳答案
你可以尝试这样的事情,不知道它是否完全符合你的要求(根据你的代码,32 是你的 wibox 的高度):
local const = wibox.layout.constraint()
const:set_widget(layout)
const:set_strategy("exact")
const:set_height(32/2)
local l = wibox.layout.fixed.vertical()
l:add(const)
l:add(mytasklist[s])
mywibox[s]:set_widget(l)
首先,它创建一个“约束”布局,确保布局“布局”(应显示在顶部的小部件)的大小始终为 16 像素。然后它将此约束布局堆叠到任务列表之上,并在 wibox 中显示结果。
部分代码在最新版本中可能会缩短一些,但我不确定 3.5.1 是否已经有了这些方便的参数。
关于lua - Awesome 3.5 - 顶部有两个面板(wiboxes),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19479950/