diff --git a/common/draw.h b/common/draw.h index b5933f51..874b0f71 100644 --- a/common/draw.h +++ b/common/draw.h @@ -118,8 +118,9 @@ typedef struct } draw_image_t; draw_context_t *draw_context_new(xcb_connection_t *, int, int, int, xcb_drawable_t, xcolor_t, xcolor_t); -/** Delete a draw context - * \param ctx draw_context_t to delete + +/** Delete a draw context. + * \param ctx The draw_context_t to delete. */ static inline void draw_context_delete(draw_context_t **ctx) diff --git a/statusbar.c b/statusbar.c index b0db560c..b5be5450 100644 --- a/statusbar.c +++ b/statusbar.c @@ -340,6 +340,47 @@ luaA_statusbar_align_set(lua_State *L) return 0; } +/** Set the default statusbar colors outside the constructor + * \param L The Lua VM state. + * \return The number of elements pushed on the stack. + * + * \luastack + * \lvalue A statusbar. + * \lparam A table with `bg' and `fg'. + */ +static int +luaA_statusbar_colors_set(lua_State *L) +{ + statusbar_t **sb = luaA_checkudata(L, 1, "statusbar"); + const char *buf; + + luaA_checktable(L, 2); + + if ((buf = luaA_getopt_string(L, 2, "fg", NULL))) + { + xcolor_new(globalconf.connection, globalconf.default_screen, + buf, &(*sb)->colors.fg); + + if((*sb)->ctx) + (*sb)->ctx->fg = (*sb)->colors.fg; + + (*sb)->need_update = true; + } + + if ((buf = luaA_getopt_string(L, 2, "bg", NULL))) + { + xcolor_new(globalconf.connection, globalconf.default_screen, + buf, &(*sb)->colors.bg); + + if((*sb)->ctx) + (*sb)->ctx->bg = (*sb)->colors.bg; + + (*sb)->need_update = true; + } + + return 0; +} + /** Convert a statusbar to a printable string. * \param L The Lua VM state. * @@ -572,6 +613,7 @@ const struct luaL_reg awesome_statusbar_meta[] = { "position_set", luaA_statusbar_position_set }, { "position_get", luaA_statusbar_position_get }, { "align_set", luaA_statusbar_align_set }, + { "colors_set", luaA_statusbar_colors_set }, { "add", luaA_statusbar_add }, { "remove", luaA_statusbar_remove }, { "__gc", luaA_statusbar_gc },