lua: expand package.path more
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
330f4304c0
commit
18fab522f9
10
lua.c
10
lua.c
|
@ -562,7 +562,7 @@ luaA_parserc(const char *confpatharg)
|
||||||
{
|
{
|
||||||
int screen;
|
int screen;
|
||||||
const char *confdir, *xdg_config_dirs;
|
const char *confdir, *xdg_config_dirs;
|
||||||
char *confpath = NULL, **xdg_files, **buf;
|
char *confpath = NULL, **xdg_files, **buf, path[1024];
|
||||||
ssize_t len;
|
ssize_t len;
|
||||||
|
|
||||||
if(confpatharg)
|
if(confpatharg)
|
||||||
|
@ -580,6 +580,9 @@ luaA_parserc(const char *confpatharg)
|
||||||
len += sizeof(AWESOME_CONFIG_FILE);
|
len += sizeof(AWESOME_CONFIG_FILE);
|
||||||
confpath = p_new(char, len);
|
confpath = p_new(char, len);
|
||||||
a_strcpy(confpath, len, confdir);
|
a_strcpy(confpath, len, confdir);
|
||||||
|
/* update package.path */
|
||||||
|
snprintf(path, sizeof(path) - 1, "package.path = package.path .. \";%s/awesome/?.lua\"", confdir);
|
||||||
|
luaA_dostring(globalconf.L, path);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -588,6 +591,9 @@ luaA_parserc(const char *confpatharg)
|
||||||
confpath = p_new(char, len);
|
confpath = p_new(char, len);
|
||||||
a_strcpy(confpath, len, confdir);
|
a_strcpy(confpath, len, confdir);
|
||||||
a_strcat(confpath, len, XDG_CONFIG_HOME_DEFAULT);
|
a_strcat(confpath, len, XDG_CONFIG_HOME_DEFAULT);
|
||||||
|
/* update package.path */
|
||||||
|
snprintf(path, sizeof(path) - 1, "package.path = package.path .. \";%s" XDG_CONFIG_HOME_DEFAULT "/awesome/?.lua\"", confdir);
|
||||||
|
luaA_dostring(globalconf.L, path);
|
||||||
}
|
}
|
||||||
a_strcat(confpath, len, AWESOME_CONFIG_FILE);
|
a_strcat(confpath, len, AWESOME_CONFIG_FILE);
|
||||||
|
|
||||||
|
@ -613,6 +619,8 @@ luaA_parserc(const char *confpatharg)
|
||||||
confpath = p_new(char, len);
|
confpath = p_new(char, len);
|
||||||
a_strcpy(confpath, len, *buf);
|
a_strcpy(confpath, len, *buf);
|
||||||
a_strcat(confpath, len, AWESOME_CONFIG_FILE);
|
a_strcat(confpath, len, AWESOME_CONFIG_FILE);
|
||||||
|
snprintf(path, sizeof(path) - 1, "package.path = package.path .. \";%s/awesome/?.lua\"", *buf);
|
||||||
|
luaA_dostring(globalconf.L, path);
|
||||||
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
|
||||||
|
|
2
lua.h
2
lua.h
|
@ -71,7 +71,7 @@ typedef int luaA_function;
|
||||||
|
|
||||||
#define luaA_dostring(L, cmd) \
|
#define luaA_dostring(L, cmd) \
|
||||||
do { \
|
do { \
|
||||||
if(cmd) \
|
if(a_strlen(cmd)) \
|
||||||
if(luaL_dostring(L, cmd)) \
|
if(luaL_dostring(L, cmd)) \
|
||||||
warn("error executing Lua code: %s", \
|
warn("error executing Lua code: %s", \
|
||||||
lua_tostring(L, -1)); \
|
lua_tostring(L, -1)); \
|
||||||
|
|
Loading…
Reference in New Issue