Search code examples
awesome-wm

Center position tasklist when using layout.fixed


I'm using the following settings for my top bar:

  -- Create a promptbox for each screen
  s.mypromptbox = awful.widget.prompt()

  -- Create a taglist widget
  s.mytaglist = awful.widget.taglist(s, awful.widget.taglist.filter.all, taglist_buttons)

  -- Create a tasklist widget
  s.mytasklist = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, tasklist_buttons)

  -- Create the wibox
  s.mywibox = awful.wibar({ position = theme.position, screen = s, height = theme.height })

  -- Add widgets to the wibox
  s.mywibox:setup {
    layout = wibox.layout.align.horizontal,
    {
      -- Left widgets
        layout = wibox.layout.fixed.horizontal,
        s.mytaglist,
        s.mypromptbox,
    },
    s.mytasklist, -- Middle widget
    {
    -- Right widgets
      layout = wibox.layout.fixed.horizontal,
      theme.systray,
      theme.spr_left,
      theme.volume,
      theme.battery,
      theme.clock,
      theme.spr_right
    },
  }

This results in: enter image description here

I have disabled the names of the tasks. What I want to accomplish is having the icons of the tasklist displayed in the center. How can I accomplish this, while preserving the tags to the left and the systray on the right?

Edit

When applying expand = outside, I get the following:

enter image description here

Edit2

When I add these container settings:

-- Tasklist container
local tl = wibox.container.background(s.mytasklist, theme.bg_normal, gears.shape.rectangle)
local pl = wibox.container.margin(tl, 2, 2, 3, 3)
local tasklist = wibox.container.place(pl, {halign="center"})

I get:

enter image description here

Which is a bit better, but still not fully centered.


Solution

  • I solved the problem by applying expand = "none" to the horizontal align. As follows:

    -- Add widgets to the wibox
    s.mywibox:setup {
        layout = wibox.layout.align.horizontal,
        expand = "none",
        {
          -- Left widgets
            layout = wibox.layout.fixed.horizontal,
            s.mytaglist,
            s.mypromptbox,
        },
          -- Middle widget
          s.mytasklist,
        {
        -- Right widgets
          layout = wibox.layout.fixed.horizontal,
          theme.systray,
          theme.spr_left,
          theme.volume,
          theme.battery,
          theme.clock,
          theme.spr_right
        },
      }
    end)
    

    Which perfectly aligns the bar as follows on Awesome v4.2-257-g59aa4ac7:

    enter image description here