lua: add awesome.conffile()

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-09-30 15:35:47 +02:00
parent caa63d43d7
commit 116de39142
2 changed files with 25 additions and 1 deletions

24
luaa.c
View File

@ -305,8 +305,22 @@ luaA_font(lua_State *L)
return 1; return 1;
} }
/** Get configuration file path used by awesome.
* \param L The Lua VM state.
* \return The number of elements pushed on stack.
* \luastack
* \lreturn The awesome configuration file path.
*/
static int
luaA_conffile(lua_State *L)
{
lua_pushstring(L, globalconf.conffile);
return 1;
}
/** Set default colors. (DEPRECATED) /** Set default colors. (DEPRECATED)
* \param L The Lua VM state. * \param L The Lua VM state.
* \return The number of elements pushed on stack.
* *
* \luastack * \luastack
* \lparam A table with `fg' and `bg' elements, containing colors. * \lparam A table with `fg' and `bg' elements, containing colors.
@ -593,6 +607,7 @@ luaA_init(void)
{ "colors_set", luaA_colors_set }, { "colors_set", luaA_colors_set },
{ "font", luaA_font }, { "font", luaA_font },
{ "colors", luaA_colors }, { "colors", luaA_colors },
{ "conffile", luaA_conffile },
{ NULL, NULL } { NULL, NULL }
}; };
static const struct luaL_reg awesome_hooks_lib[] = static const struct luaL_reg awesome_hooks_lib[] =
@ -703,7 +718,10 @@ luaA_parserc(const char *confpatharg)
if(luaL_dofile(globalconf.L, confpatharg)) if(luaL_dofile(globalconf.L, confpatharg))
fprintf(stderr, "%s\n", lua_tostring(globalconf.L, -1)); fprintf(stderr, "%s\n", lua_tostring(globalconf.L, -1));
else else
{
globalconf.conffile = a_strdup(confpatharg);
goto bailout; goto bailout;
}
} }
confdir = getenv("XDG_CONFIG_HOME"); confdir = getenv("XDG_CONFIG_HOME");
@ -733,7 +751,10 @@ luaA_parserc(const char *confpatharg)
if(luaL_dofile(globalconf.L, confpath)) if(luaL_dofile(globalconf.L, confpath))
fprintf(stderr, "%s\n", lua_tostring(globalconf.L, -1)); fprintf(stderr, "%s\n", lua_tostring(globalconf.L, -1));
else else
{
globalconf.conffile = a_strdup(confpath);
goto bailout; goto bailout;
}
xdg_config_dirs = getenv("XDG_CONFIG_DIRS"); xdg_config_dirs = getenv("XDG_CONFIG_DIRS");
@ -757,7 +778,10 @@ luaA_parserc(const char *confpatharg)
if(luaL_dofile(globalconf.L, confpath)) if(luaL_dofile(globalconf.L, confpath))
fprintf(stderr, "%s\n", lua_tostring(globalconf.L, -1)); fprintf(stderr, "%s\n", lua_tostring(globalconf.L, -1));
else else
{
globalconf.conffile = a_strdup(confpath);
break; break;
}
} }
for(buf = xdg_files; *buf; buf++) for(buf = xdg_files; *buf; buf++)

View File

@ -405,7 +405,7 @@ struct awesome_t
/** Embedded windows */ /** Embedded windows */
xembed_window_t *embedded; xembed_window_t *embedded;
/** Path to config file */ /** Path to config file */
char *configpath; char *conffile;
/** Stack client history */ /** Stack client history */
client_node_t *stack; client_node_t *stack;
/** Command line passed to awesome */ /** Command line passed to awesome */