On 12.12.2011 23:39, Ellie Frost wrote:
Hello all,

I've finally gotten around to adding a few gauges and such to my
wibox, but I don't like them all squashed to one side. I'm trying to
get them to be centred in the wibox between the tag lists on the left
and the clock/system tray on the right (I don't have a task list). I
have them in a group (fixed.horizontal()) set with set_middle, but
they just left align themselves. Is this possible to do?

$ awesome --version
awesome v3.4-595-g47238fe (Closing In)
  • Build: Dec  8 2011 00:59:21 for x86_64 by gcc version 4.6.2 (sib@westley)
  • D-Bus support: ✔

Ellie

:set_middle() is going towards the right direction, but doesn't do exactly what you want. It does give the widget all the available space, but it doesn't center anything.

If you have right now:

  layout:set_middle(stuff)

change that into... Oh, wait, we don't have any "center" layout yet. Ouch.

Ok, this might get a little longer (and I'd be amazed if I get it right on the first try).

 local center = wibox.widget.base.make_widget()
 center.fit = function(_, width, height) return width, height end
 center.draw = function(_, wibox, cr, width, height)
   local w, h = stuff:fit(width, height)
   local x = (width - w) / 2
   wibox.layout.base.draw_widget(wibox, cr, stuff, x, 0, w, height)
 end
 layout:set_middle(center)

This code invents a new layout. When asked how much space the layout wants, it just answers "all that you got". When it is told to draw a widget, it centers the widget "stuff" horizontally in the middle of the avaiable area. Centering it vertically doesn't necessarily make sense since that would mis-place text.

Sorry, I don't have the time right now to test if this works. Good Luck.

If this code doesn't cause lua errors, please show your rc.lua (with this chunk built in) and I will try to take a closer look. If it does cause lua errors...

Cheers,
Uli

--
To unsubscribe, send mail to [email protected].

Reply via email to