From f95449a4bb40f2215c756602173129d7b39a9ae9 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sun, 24 Jul 2016 14:51:52 +0200 Subject: [PATCH 1/3] man pages: Update synopsis Signed-off-by: Uli Schlachter --- manpages/awesome.1.de.txt | 2 +- manpages/awesome.1.es.txt | 2 +- manpages/awesome.1.fr.txt | 2 +- manpages/awesome.1.it.txt | 2 +- manpages/awesome.1.ru.txt | 2 +- manpages/awesome.1.txt | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/manpages/awesome.1.de.txt b/manpages/awesome.1.de.txt index 4b7404653..99dce653e 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*] +*awesome* [*-v* | *--version*] [*-h* | *--help*] [*-c* | *--config* 'Datei'] [*-k* | *--check*] [*-a* | *--no-argb*] [*-r* | *--replace] BESCHREIBUNG ----------- diff --git a/manpages/awesome.1.es.txt b/manpages/awesome.1.es.txt index 37c11694e..7b9d03196 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*] +*awesome* [*-v* | *--version*] [*-h* | *--help*] [*-c* | *--config* 'FICHERO'] [*-k* | *--check*] [*-a* | *--no-argb*] [*-r* | *--replace] DESCRIPCIÓN ----------- diff --git a/manpages/awesome.1.fr.txt b/manpages/awesome.1.fr.txt index 00da895c5..dbb73fc18 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*] +*awesome* [*-v* | *--version*] [*-h* | *--help*] [*-c* | *--config* 'FILE'] [*-k* | *--check*] [*-a* | *--no-argb*] [*-r* | *--replace] DESCRIPTION ----------- diff --git a/manpages/awesome.1.it.txt b/manpages/awesome.1.it.txt index 5ae1057dc..caa6ddb14 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*] +*awesome* [*-v* | *--version*] [*-h* | *--help*] [*-c* | *--config* 'FILE'] [*-k* | *--check*] [*-a* | *--no-argb*] [*-r* | *--replace] DESCRIZIONE ----------- diff --git a/manpages/awesome.1.ru.txt b/manpages/awesome.1.ru.txt index 5048b96fe..c09ddb57e 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*] +*awesome* [*-v* | *--version*] [*-h* | *--help*] [*-c* | *--config* 'FILE'] [*-k* | *--check*] [*-a* | *--no-argb*] [*-r* | *--replace] ОПИСАНИЕ -------- diff --git a/manpages/awesome.1.txt b/manpages/awesome.1.txt index 17f52bfa2..8ef3195a4 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*] +*awesome* [*-v* | *--version*] [*-h* | *--help*] [*-c* | *--config* 'FILE'] [*-k* | *--check*] [*-a* | *--no-argb*] [*-r* | *--replace] DESCRIPTION ----------- From 24bb38969d6822cb284c9cf541f824b000540796 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sun, 24 Jul 2016 14:57:14 +0200 Subject: [PATCH 2/3] Add an option to add a path to $LUA_PATH The same effect could be achieved by modifying $LUA_PATH or with symlinks, but having a special option to do this seems easier. Note that the man page translations were generated via Google translate. I'm looking forward to people submitting correct translations... Inspired-by: https://github.com/awesomeWM/awesome/pull/485 Signed-off-by: Uli Schlachter --- awesome.c | 23 +++++++++++++++++------ luaa.c | 29 ++++++++++++++++++++--------- luaa.h | 9 ++++++++- manpages/awesome.1.de.txt | 4 +++- manpages/awesome.1.es.txt | 4 +++- manpages/awesome.1.fr.txt | 4 +++- manpages/awesome.1.it.txt | 4 +++- manpages/awesome.1.ru.txt | 4 +++- manpages/awesome.1.txt | 4 +++- 9 files changed, 63 insertions(+), 22 deletions(-) diff --git a/awesome.c b/awesome.c index db4221f11..ef5d18f62 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 2143f39d1..ac0d3bb15 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 6d34492d8..01a03ec60 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 99dce653e..8a1ea4d8b 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 7b9d03196..45901a909 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 dbb73fc18..140ee5d53 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 caa6ddb14..559c152d0 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 c09ddb57e..fb9f7e141 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 8ef3195a4..bd45c9987 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*:: From 71049a67f7674b60f53d8574d8b03267c9c54cc8 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sun, 24 Jul 2016 15:03:05 +0200 Subject: [PATCH 3/3] tests/run.sh: Use --search instead of $LUA_PATH Signed-off-by: Uli Schlachter --- tests/run.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/run.sh b/tests/run.sh index 592354f13..19de14869 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -82,11 +82,10 @@ fi cd $build_dir -LUA_PATH="$(lua -e 'print(package.path)');lib/?.lua;lib/?/init.lua" +AWESOME_OPTIONS="$AWESOME_OPTIONS --search lib/" # Add test dir (for _runner.lua). -LUA_PATH="$LUA_PATH;$this_dir/?.lua" +AWESOME_OPTIONS="$AWESOME_OPTIONS --search $this_dir" XDG_CONFIG_HOME="./" -export LUA_PATH export XDG_CONFIG_HOME cd - >/dev/null