Question

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.

Was it helpful?

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.

OTHER TIPS

I've done similar with following code:

wiboxes["top"]=awful.wibox({position="top",height=26})
local top_layout = wibox.layout.fixed.horizontal()
sublayout["cpu"] = wibox.layout.fixed.horizontal()
for i=2,3 do
  sublayout["cpu" .. i] = wibox.layout.fixed.horizontal()
  sublayout["cpu" .. i]:add(graphs["cpu"]..i) -- the graphs table already initialized
  sublayout["cpu" .. i]:add(textboxes["cpu"]..i) -- textboxes table already initialized
  sublayout["cpu"]:add(sublayout["cpu"..i)
end
.....
top_layout:add(sublayout["cpu"])
.....
wiboxes["top"]:set_widget(top_layout)

With this code I've two graphs and textboxes to see the CPUs usage (every core), first is on top, second is down. It should work with taglist or any other widget.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top