From ac2d026d5990063b505d563f9bb54f8daae5474d Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Sun, 10 May 2009 15:01:22 +0200 Subject: [PATCH] root: add wiboxes() method to get wiboxes Signed-off-by: Julien Danjou --- root.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/root.c b/root.c index 9d411d44..61c4a866 100644 --- a/root.c +++ b/root.c @@ -23,6 +23,7 @@ #include "structs.h" #include "button.h" +#include "wibox.h" #include "common/xcursor.h" #include "common/tokenize.h" #include "common/xutil.h" @@ -175,12 +176,33 @@ luaA_root_cursor(lua_State *L) return 0; } +/** Get the wiboxes attached to a screen. + * \param L The Lua VM state. + * \return The number of element pushed on stack. + * \luastack + * \lreturn A table with all wiboxes. + */ +static int +luaA_root_wiboxes(lua_State *L) +{ + lua_createtable(L, globalconf.wiboxes.len, 0); + + for(int i = 0; i < globalconf.wiboxes.len; i++) + { + wibox_push(L, globalconf.wiboxes.tab[i]); + lua_rawseti(L, -2, i + 1); + } + + return 1; +} + const struct luaL_reg awesome_root_lib[] = { { "buttons", luaA_root_buttons }, { "keys", luaA_root_keys }, { "cursor", luaA_root_cursor }, { "fake_input", luaA_root_fake_input }, + { "wiboxes", luaA_root_wiboxes }, { NULL, NULL } };