Skip to content

Instantly share code, notes, and snippets.

@SkyyySi
Last active January 25, 2022 10:21
Show Gist options
  • Select an option

  • Save SkyyySi/910aab3a8127b142e8fc1a72525087b4 to your computer and use it in GitHub Desktop.

Select an option

Save SkyyySi/910aab3a8127b142e8fc1a72525087b4 to your computer and use it in GitHub Desktop.
Center a widget spawned from a button in awesome wm
your_button:connect_signal("button:press", function(_,_,_,button)
if button == 1 then -- Check which mouse button is used; 1 = left click.
your_drawable.visible = not your_drawable.visible -- not related to placement
awful.placement.align(your_drawable, {
position = "top",
honor_workarea = true,
margins = { -- 10 pixels *in addition to the width of your panel(s)*!
top = 10,
},
})
your_drawable.x = mouse.current_widget_geometry.x +
s.geometry.x +
mouse.current_widget_geometry.width / 2 -
your_drawable.width / 2
end
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment