diff --git a/awesome.c b/awesome.c index eb347d60f..6a289842e 100644 --- a/awesome.c +++ b/awesome.c @@ -490,6 +490,7 @@ main(int argc, char **argv) p_clear(&globalconf, 1); globalconf.keygrabber = LUA_REFNIL; globalconf.mousegrabber = LUA_REFNIL; + globalconf.exit_code = EXIT_SUCCESS; buffer_init(&globalconf.startup_errors); string_array_init(&searchpath); @@ -754,7 +755,7 @@ main(int argc, char **argv) awesome_atexit(false); - return EXIT_SUCCESS; + return globalconf.exit_code; } // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/globalconf.h b/globalconf.h index 2560531b6..cab3364d6 100644 --- a/globalconf.h +++ b/globalconf.h @@ -194,6 +194,8 @@ typedef struct window_array_t destroy_later_windows; /** Pending event that still needs to be handled */ xcb_generic_event_t *pending_event; + /** The exit code that main() will return with */ + int exit_code; } awesome_t; extern awesome_t globalconf; diff --git a/luaa.c b/luaa.c index 8c718b7a3..e5cd05564 100644 --- a/luaa.c +++ b/luaa.c @@ -155,11 +155,14 @@ composite_manager_running(void) } /** Quit awesome. + * @tparam[opt=0] integer code The exit code to use when exiting. * @function quit */ static int luaA_quit(lua_State *L) { + if (!lua_isnoneornil(L, 1)) + globalconf.exit_code = luaL_checkinteger(L, 1); if (globalconf.loop == NULL) globalconf.loop = g_main_loop_new(NULL, FALSE); g_main_loop_quit(globalconf.loop);