Search code examples
luaawesome-wm

Awesome 3.5 - two panels (wiboxes) at the top


Before migrating to Awesome 3.5.1 I had two panels at the top of my screen (on top of each other, sort of) and none at the bottom. The code I used to achieve this pre-3.5.* is below:

-- 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
}

Now I'm having a hard time trying to figure out how to achieve the same with the 3.5 configuration. At the moment I use pretty basic one panel (with most of the widgets) on top, and one (with the tasklist) at the bottom. The code can be seen below:

    -- 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)

If anyone has ideas how to edit my current rc.lua to make it work as the upper code did in Awesome 3.4.*, that'd be greatly appreciated.


Solution

  • You could try something like this, no idea if it does exactly what you want (32 is the height of your wibox according to your code):

    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)
    

    First it creates a "constraint" layout which makes sure that the layout "layout" (the widgets that should be shown on the top) always get a size of 16px. Then it stacks this constraint layout ontop of the tasklist and displays the result in the wibox.

    Some of this code could be shortened a bit in the latest version, but I am not sure if 3.5.1 has those convenience arguments already.