AwesomeWM concept of "buttons" can be split into 2 APIs. First of all, there is the button widget, which actually doesn't do much and is just a glorified wibox.widget.imagebox
. This is the part not super relevant to your question.
The other part, which is relevant, is the event model. There are 2 ways to get something to happen when you click on a widget. The first one are the signals. Each widget has a button::press
, button::release
, mouse::enter
and mouse::leave
signals. You can attach a function to a signal this way:
mytextclock:connect_signal("button::press", function(self, lx, ly, button, mods, metadata)
wibox.widget.calendar.year(os.date('*t'))
end)
That API is more rich than a simple button. You get a lot of geometry and layout information you don't get from awful.button
. However, it is overkill for simple buttons, thus awful.button
.
Each widget has a :buttons()
method in AwesomeWM < v4.4 or a .buttons
object property in AwesomeWM >= v4.4. There are several examples in rc.lua
of how to add some awful.buttons
to these widget. Here are the snippets for the mylayoutbox
widget:
For < v4.4:
s.mylayoutbox:buttons(gears.table.join(
awful.button({ }, 1, function () awful.layout.inc( 1) end),
awful.button({ }, 3, function () awful.layout.inc(-1) end),
awful.button({ }, 4, function () awful.layout.inc( 1) end),
awful.button({ }, 5, function () awful.layout.inc(-1) end)))
for >= v4.4:
s.mylayoutbox = awful.widget.layoutbox {
screen = s
}
s.mylayoutbox.buttons = {
awful.button({ }, 1, function () awful.layout.inc( 1) end),
awful.button({ }, 3, function () awful.layout.inc(-1) end),
awful.button({ }, 4, function () awful.layout.inc(-1) end),
awful.button({ }, 5, function () awful.layout.inc( 1) end),
}
-- That works too.
s.mylayoutbox:add_button(awful.button({ }, 1, function () awful.layout.inc( 1) end))
As for the lack of examples in the documentation. That's a fair point. I will add some.