From c3d16391f51711857ea18a8f2087853afe6958ba Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Tue, 27 May 2008 16:04:05 +0200 Subject: [PATCH] [statusbar] Add position_get() function for statusbars Signed-off-by: Julien Danjou --- awesomerc.lua.in | 12 +++++++----- statusbar.c | 12 ++++++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/awesomerc.lua.in b/awesomerc.lua.in index 03db2ca9..1dc3beae 100644 --- a/awesomerc.lua.in +++ b/awesomerc.lua.in @@ -95,8 +95,13 @@ mydebugbar = statusbar.new({ position = "off", name = "mydebugbar", fg = "white", bg = "black" }) mydebugbar:widget_add(mydebugbox) mydebugbar:add(1) -awesome.key({ modkey }, "d", function () mydebugbar:position_set("bottom") end) -awesome.key({ modkey, "Control" }, "d", function () mydebugbar:position_set("off") end) +awesome.key({ modkey }, "d", function () + if mydebugbar:position_get() == "off" then + mydebugbar:position_set("bottom") + else + mydebugbar:position_set("off") + end + end) -- }}} -- {{{ Mouse bindings @@ -167,9 +172,6 @@ awesome.key({ modkey, "Control" }, "j", function () awful.screen.focus(1) end) awesome.key({ modkey, "Control" }, "k", function () awful.screen.focus(-1) end) awesome.key({ modkey, "Control" }, "space", function () awful.client.togglefloating() end) --- Statubar manipulation -awesome.key({ modkey }, "b", function () mystatusbar:position_set("off") end) - -- Layout manipulation awesome.key({ modkey }, "l", function () awful.tag.incmwfact(0.05) end) awesome.key({ modkey }, "h", function () awful.tag.incmwfact(-0.05) end) diff --git a/statusbar.c b/statusbar.c index 681aa3df..e7901841 100644 --- a/statusbar.c +++ b/statusbar.c @@ -348,6 +348,17 @@ luaA_statusbar_position_set(lua_State *L) return 0; } +/** Get the statusbar position. + * \return The statusbar position. + */ +static int +luaA_statusbar_position_get(lua_State *L) +{ + statusbar_t **sb = luaL_checkudata(L, 1, "statusbar"); + lua_pushstring(L, position_to_str((*sb)->position)); + return 1; +} + static int luaA_statusbar_align_set(lua_State *L) { @@ -504,6 +515,7 @@ const struct luaL_reg awesome_statusbar_meta[] = { { "widget_add", luaA_statusbar_widget_add }, { "position_set", luaA_statusbar_position_set }, + { "position_get", luaA_statusbar_position_get }, { "align_set", luaA_statusbar_align_set }, { "add", luaA_statusbar_add }, { "remove", luaA_statusbar_remove },