diff --git a/awesomeConfig.cmake b/awesomeConfig.cmake index c10109b1..7bdd54f8 100644 --- a/awesomeConfig.cmake +++ b/awesomeConfig.cmake @@ -135,6 +135,7 @@ pkg_check_modules(AWESOME_COMMON_REQUIRED REQUIRED xcb>=1.1) pkg_check_modules(AWESOME_REQUIRED REQUIRED + glib-2.0 cairo x11 pango>=1.19.3 diff --git a/awesomerc.lua.in b/awesomerc.lua.in index 483d6713..d3d904c2 100644 --- a/awesomerc.lua.in +++ b/awesomerc.lua.in @@ -242,7 +242,8 @@ globalkeys = awful.util.table.join( function () awful.prompt.run({ prompt = "Run: " }, mypromptbox[mouse.screen], - awful.util.spawn, awful.completion.shell, + function (...) mypromptbox[mouse.screen].text = awful.util.spawn(unpack(arg)) end, + awful.completion.shell, awful.util.getdir("cache") .. "/history") end), diff --git a/spawn.c b/spawn.c index bb35b3a8..34a107d1 100644 --- a/spawn.c +++ b/spawn.c @@ -24,6 +24,8 @@ #include #include +#include + #include "spawn.h" #include "screen.h" #include "luaa.h" @@ -228,6 +230,7 @@ spawn_launchee_timeout(struct ev_loop *loop, ev_timer *w, int revents) * \lparam The command to launch. * \lparam Use startup-notification, true or false, default to true. * \lparam The optional screen number to spawn the command on. + * \lreturn Nothing if launch was successful, an error string otherwise. */ int luaA_spawn(lua_State *L) @@ -256,6 +259,7 @@ luaA_spawn(lua_State *L) p_delete(&host); } + SnLauncherContext *context = NULL; if(use_sn) { char *cmdname, *space; @@ -264,7 +268,7 @@ luaA_spawn(lua_State *L) else cmdname = a_strdup(cmd); - SnLauncherContext *context = sn_launcher_context_new(globalconf.sndisplay, screen_virttophys(screen)); + context = sn_launcher_context_new(globalconf.sndisplay, screen_virttophys(screen)); sn_launcher_context_set_name(context, "awesome"); sn_launcher_context_set_description(context, "awesome spawn"); sn_launcher_context_set_binary_name(context, cmdname); @@ -280,21 +284,16 @@ luaA_spawn(lua_State *L) sn_launcher_context_setup_child_process(context); } - /* The double-fork construct avoids zombie processes and keeps the code - * clean from stupid signal handlers. */ - if(fork() == 0) + GError *error = NULL; + if(!g_spawn_command_line_async(cmd, &error)) { - if(fork() == 0) - { - if(globalconf.connection) - xcb_disconnect(globalconf.connection); - setsid(); - a_exec(cmd); - warn("execl '%s' failed: %s\n", cmd, strerror(errno)); - } - exit(EXIT_SUCCESS); + /* push error on stack */ + lua_pushstring(L, error->message); + g_error_free(error); + if(context) + sn_launcher_context_complete(context); + return 1; } - wait(0); return 0; }