diff --git a/awesome.c b/awesome.c index db4221f1..ef5d18f6 100644 --- a/awesome.c +++ b/awesome.c @@ -429,6 +429,7 @@ exit_help(int exit_code) -h, --help show help\n\ -v, --version show version\n\ -c, --config FILE configuration file to use\n\ + --search DIR add a directory to the library search path\n\ -k, --check check configuration file syntax\n\ -a, --no-argb disable client transparency support\n\ -r, --replace replace an existing window manager\n"); @@ -444,6 +445,7 @@ int main(int argc, char **argv) { char *confpath = NULL; + string_array_t searchpath; int xfd, i, opt; ssize_t cmdlen = 1; xdgHandle xdg; @@ -457,6 +459,7 @@ main(int argc, char **argv) { "version", 0, NULL, 'v' }, { "config", 1, NULL, 'c' }, { "check", 0, NULL, 'k' }, + { "search", 1, NULL, 's' }, { "no-argb", 0, NULL, 'a' }, { "replace", 0, NULL, 'r' }, { NULL, 0, NULL, 0 } @@ -471,6 +474,7 @@ main(int argc, char **argv) globalconf.keygrabber = LUA_REFNIL; globalconf.mousegrabber = LUA_REFNIL; buffer_init(&globalconf.startup_errors); + string_array_init(&searchpath); /* save argv */ for(i = 0; i < argc; i++) @@ -488,12 +492,6 @@ main(int argc, char **argv) /* Text won't be printed correctly otherwise */ setlocale(LC_CTYPE, ""); - /* Get XDG basedir data */ - xdgInitHandle(&xdg); - - /* init lua */ - luaA_init(&xdg); - /* check args */ while((opt = getopt_long(argc, argv, "vhkc:ar", long_options, NULL)) != -1) @@ -514,6 +512,12 @@ main(int argc, char **argv) else fatal("-c option requires a file name"); break; + case 's': + if(a_strlen(optarg)) + string_array_append(&searchpath, a_strdup(optarg)); + else + fatal("-s option requires a directory name"); + break; case 'a': no_argb = true; break; @@ -522,6 +526,13 @@ main(int argc, char **argv) break; } + /* Get XDG basedir data */ + xdgInitHandle(&xdg); + + /* init lua */ + luaA_init(&xdg, &searchpath); + string_array_wipe(&searchpath); + if (run_test) { if(!luaA_parserc(&xdg, confpath, false)) diff --git a/luaa.c b/luaa.c index 2143f39d..ac0d3bb1 100644 --- a/luaa.c +++ b/luaa.c @@ -590,7 +590,7 @@ setup_awesome_signals(lua_State *L) * \param xdg An xdg handle to use to get XDG basedir. */ void -luaA_init(xdgHandle* xdg) +luaA_init(xdgHandle* xdg, string_array_t *searchpath) { lua_State *L; static const struct luaL_Reg awesome_lib[] = @@ -681,6 +681,19 @@ luaA_init(xdgHandle* xdg) /* Export keys */ key_class_setup(L); + /* add XDG_CONFIG_DIR as include path */ + const char * const *xdgconfigdirs = xdgSearchableConfigDirectories(xdg); + for(; *xdgconfigdirs; xdgconfigdirs++) + { + /* Append /awesome to *xdgconfigdirs */ + const char *suffix = "/awesome"; + size_t len = a_strlen(*xdgconfigdirs) + a_strlen(suffix) + 1; + char *entry = p_new(char, len); + a_strcat(entry, len, *xdgconfigdirs); + a_strcat(entry, len, suffix); + string_array_append(searchpath, entry); + } + /* add Lua search paths */ lua_getglobal(L, "package"); if (LUA_TTABLE != lua_type(L, 1)) @@ -696,19 +709,17 @@ luaA_init(xdgHandle* xdg) return; } - /* add XDG_CONFIG_DIR as include path */ - const char * const *xdgconfigdirs = xdgSearchableConfigDirectories(xdg); - for(; *xdgconfigdirs; xdgconfigdirs++) + foreach(entry, *searchpath) { - size_t len = a_strlen(*xdgconfigdirs); + size_t len = a_strlen(*entry); lua_pushliteral(L, ";"); - lua_pushlstring(L, *xdgconfigdirs, len); - lua_pushliteral(L, "/awesome/?.lua"); + lua_pushlstring(L, *entry, len); + lua_pushliteral(L, "/?.lua"); lua_concat(L, 3); lua_pushliteral(L, ";"); - lua_pushlstring(L, *xdgconfigdirs, len); - lua_pushliteral(L, "/awesome/?/init.lua"); + lua_pushlstring(L, *entry, len); + lua_pushliteral(L, "/?/init.lua"); lua_concat(L, 3); lua_concat(L, 3); /* concatenate with package.path */ diff --git a/luaa.h b/luaa.h index 6d34492d..01a03ec6 100644 --- a/luaa.h +++ b/luaa.h @@ -39,6 +39,13 @@ signal_object_emit(L, &global_signals, "debug::deprecation", 1); \ } while(0) +static inline void free_string(char **c) +{ + p_delete(c); +} + +DO_ARRAY(char*, string, free_string) + /** Print a warning about some Lua code. * This is less mean than luaL_error() which setjmp via lua_error() and kills * everything. This only warn, it's up to you to then do what's should be done. @@ -296,7 +303,7 @@ luaA_registerfct(lua_State *L, int idx, int *fct) return luaA_register(L, idx, fct); } -void luaA_init(xdgHandle *); +void luaA_init(xdgHandle *, string_array_t *); bool luaA_parserc(xdgHandle *, const char *, bool); /** Global signals */ diff --git a/manpages/awesome.1.de.txt b/manpages/awesome.1.de.txt index 99dce653..8a1ea4d8 100644 --- a/manpages/awesome.1.de.txt +++ b/manpages/awesome.1.de.txt @@ -9,7 +9,7 @@ awesome - awesome Fenstermanager SYNTAX -------- -*awesome* [*-v* | *--version*] [*-h* | *--help*] [*-c* | *--config* 'Datei'] [*-k* | *--check*] [*-a* | *--no-argb*] [*-r* | *--replace] +*awesome* [*-v* | *--version*] [*-h* | *--help*] [*-c* | *--config* 'Datei'] [*-k* | *--check*] [*--search* 'Verzeichnis'] [*-a* | *--no-argb*] [*-r* | *--replace] BESCHREIBUNG ----------- @@ -33,6 +33,8 @@ OPTIONEN Nutzung einer alternativen Konfigurationsdatei, statt '$XDG_CONFIG_HOME/awesome/rc.lua'. *-k*, *--check*:: Überprüft die Konfigurationsdatei auf Syntaxfehler. +*--search*:: + Füge ein Verzeichnis zum Bibliothekssuchpfad hinzu. *-a*, *--no-argb*:: Verwende keine ARGB-Visuals *-r*, *--replace*:: diff --git a/manpages/awesome.1.es.txt b/manpages/awesome.1.es.txt index 7b9d0319..45901a90 100644 --- a/manpages/awesome.1.es.txt +++ b/manpages/awesome.1.es.txt @@ -9,7 +9,7 @@ awesome - gestor de ventanas awesome SINOPSIS -------- -*awesome* [*-v* | *--version*] [*-h* | *--help*] [*-c* | *--config* 'FICHERO'] [*-k* | *--check*] [*-a* | *--no-argb*] [*-r* | *--replace] +*awesome* [*-v* | *--version*] [*-h* | *--help*] [*-c* | *--config* 'FICHERO'] [*-k* | *--check*] [*--search* 'DIRECTORIO'] [*-a* | *--no-argb*] [*-r* | *--replace] DESCRIPCIÓN ----------- @@ -50,6 +50,8 @@ OPCIONES '$XDG_CONFIG_HOME/awesome/rc.lua'. *-k*, *--check*:: Verifica la sintaxis del archivo de configuración. +*--search*:: + Añadir un directorio a la ruta de búsqueda de biblioteca. *-a*, *--no-argb*:: No utilice colores ARGB. *-r*, *--replace*:: diff --git a/manpages/awesome.1.fr.txt b/manpages/awesome.1.fr.txt index dbb73fc1..140ee5d5 100644 --- a/manpages/awesome.1.fr.txt +++ b/manpages/awesome.1.fr.txt @@ -9,7 +9,7 @@ awesome - gestionnaire de fenêtres awesome SYNOPSIS -------- -*awesome* [*-v* | *--version*] [*-h* | *--help*] [*-c* | *--config* 'FILE'] [*-k* | *--check*] [*-a* | *--no-argb*] [*-r* | *--replace] +*awesome* [*-v* | *--version*] [*-h* | *--help*] [*-c* | *--config* 'FILE'] [*-k* | *--check*] [*--search* 'DIRECTORY'] [*-a* | *--no-argb*] [*-r* | *--replace] DESCRIPTION ----------- @@ -43,6 +43,8 @@ OPTIONS '$XDG_CONFIG_HOME/awesome/rc.lua'. *-k*, *--check*:: Vérifie la syntaxe du fichier de configuration. +*--search*:: + Ajouter un répertoire au chemin de recherche de bibliothèque. *-a*, *--no-argb*:: N'utilise pas le codage ARGB. *-r*, *--replace*:: diff --git a/manpages/awesome.1.it.txt b/manpages/awesome.1.it.txt index caa6ddb1..559c152d 100644 --- a/manpages/awesome.1.it.txt +++ b/manpages/awesome.1.it.txt @@ -10,7 +10,7 @@ awesome - gestore di finestre awesome SINOSSI -------- -*awesome* [*-v* | *--version*] [*-h* | *--help*] [*-c* | *--config* 'FILE'] [*-k* | *--check*] [*-a* | *--no-argb*] [*-r* | *--replace] +*awesome* [*-v* | *--version*] [*-h* | *--help*] [*-c* | *--config* 'FILE'] [*-k* | *--check*] [*--search* 'DIRECTORY'] [*-a* | *--no-argb*] [*-r* | *--replace] DESCRIZIONE ----------- @@ -50,6 +50,8 @@ OPZIONI '$XDG_CONFIG_HOME/awesome/rc.lua'. *-k*, *--check*:: Verifica la sintassi del file di configurazione. +*--search*:: + Aggiungere una directory al percorso di ricerca della libreria. *-a*, *--no-argb*:: Non usare visuali ARGB. *-r*, *--replace*:: diff --git a/manpages/awesome.1.ru.txt b/manpages/awesome.1.ru.txt index c09ddb57..fb9f7e14 100644 --- a/manpages/awesome.1.ru.txt +++ b/manpages/awesome.1.ru.txt @@ -9,7 +9,7 @@ awesome - потрясающий оконный менеджер СИНОПСИС -------- -*awesome* [*-v* | *--version*] [*-h* | *--help*] [*-c* | *--config* 'FILE'] [*-k* | *--check*] [*-a* | *--no-argb*] [*-r* | *--replace] +*awesome* [*-v* | *--version*] [*-h* | *--help*] [*-c* | *--config* 'FILE'] [*-k* | *--check*] [*--search* 'DIRECTORY'] [*-a* | *--no-argb*] [*-r* | *--replace] ОПИСАНИЕ -------- @@ -45,6 +45,8 @@ awesome - потрясающий оконный менеджер Использовать альтернативный конфигурационный файл вместо '$XDG_CONFIG_HOME/awesome/rc.lua'. *-k*, *--check*:: Проверить синтаксис конфигурационного файла. +*--search*:: + Добавить каталог в пути поиска библиотеки. *-a*, *--no-argb*:: Не использовать ARGB. *-r*, *--replace*:: diff --git a/manpages/awesome.1.txt b/manpages/awesome.1.txt index 8ef3195a..bd45c998 100644 --- a/manpages/awesome.1.txt +++ b/manpages/awesome.1.txt @@ -9,7 +9,7 @@ awesome - awesome window manager SYNOPSIS -------- -*awesome* [*-v* | *--version*] [*-h* | *--help*] [*-c* | *--config* 'FILE'] [*-k* | *--check*] [*-a* | *--no-argb*] [*-r* | *--replace] +*awesome* [*-v* | *--version*] [*-h* | *--help*] [*-c* | *--config* 'FILE'] [*-k* | *--check*] [*--search* 'DIRECTORY'] [*-a* | *--no-argb*] [*-r* | *--replace] DESCRIPTION ----------- @@ -42,6 +42,8 @@ OPTIONS Use an alternate configuration file instead of '$XDG_CONFIG_HOME/awesome/rc.lua'. *-k*, *--check*:: Check configuration file syntax. +*--search*:: + Add a directory to the library search path. *-a*, *--no-argb*:: Don't use ARGB visuals. *-r*, *--replace*::