diff --git a/awesome.c b/awesome.c index 54f919df9..ac1af6d2e 100644 --- a/awesome.c +++ b/awesome.c @@ -361,12 +361,6 @@ main(int argc, char **argv) xcolor_new(globalconf.connection, globalconf.default_screen, "black", &globalconf.colors.fg); xcolor_new(globalconf.connection, globalconf.default_screen, "white", &globalconf.colors.bg); - /* parse config */ - if(!confpath) - confpath = config_file(); - if (!luaA_parserc(confpath)) - eprint("failed to load/parse configuration file %s", confpath); - /* init cursors */ globalconf.cursor[CurNormal] = xutil_cursor_new(globalconf.connection, CURSOR_LEFT_PTR); globalconf.cursor[CurResize] = xutil_cursor_new(globalconf.connection, CURSOR_SIZING); @@ -378,6 +372,15 @@ main(int argc, char **argv) globalconf.cursor[CurBotRight] = xutil_cursor_new(globalconf.connection, CURSOR_BOTTOM_RIGHT_CORNER); globalconf.cursor[CurBotLeft] = xutil_cursor_new(globalconf.connection, CURSOR_BOTTOM_LEFT_CORNER); + /* init lua */ + luaA_init(); + + /* parse config */ + if(!confpath) + confpath = config_file(); + if (!luaA_parserc(confpath)) + eprint("failed to load/parse configuration file %s", confpath); + /* select for events */ const uint32_t change_win_vals[] = { diff --git a/lua.c b/lua.c index 4c9c28fca..65ab2d881 100644 --- a/lua.c +++ b/lua.c @@ -402,11 +402,12 @@ luaA_openlib(lua_State *L, const char *name, luaL_register(L, name, methods); } -bool -luaA_parserc(const char *rcfile) +/** Initialize the Lua VM + */ +void +luaA_init(void) { lua_State *L; - int screen; static const struct luaL_reg awesome_lib[] = { @@ -480,10 +481,21 @@ luaA_parserc(const char *rcfile) lua_settable(L, LUA_GLOBALSINDEX); luaA_dostring(L, "package.path = package.path .. \";" AWESOME_LUA_LIB_PATH "/?.lua\""); +} - if(luaL_dofile(L, rcfile)) +/** Load a configuration file + * + * \param rcfile The configuration file to load. + * \return True on succes, false on failure. + */ +bool +luaA_parserc(const char* rcfile) +{ + int screen; + + if(luaL_dofile(globalconf.L, rcfile)) { - fprintf(stderr, "%s\n", lua_tostring(L, -1)); + fprintf(stderr, "%s\n", lua_tostring(globalconf.L, -1)); return false; } diff --git a/lua.h b/lua.h index 2e035f97f..37469d464 100644 --- a/lua.h +++ b/lua.h @@ -133,6 +133,7 @@ luaA_checkboolean(lua_State *L, int n) return lua_toboolean(L, n); } +void luaA_init(void); bool luaA_parserc(const char *); void luaA_docmd(char *); void luaA_pushpointer(void *, awesome_type_t);