From 30aeb3f3114eb9c7e4cd8c3f91ac046f6060a778 Mon Sep 17 00:00:00 2001 From: Kristof Provost Date: Tue, 22 Jul 2008 10:23:07 +0200 Subject: [PATCH] Reload awesome on SIGHUP Signed-off-by: Julien Danjou --- awesome.c | 13 +++++++++++-- ewmh.c | 17 +++++++++++++++++ ewmh.h | 1 + lua.c | 10 +--------- 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/awesome.c b/awesome.c index 794a6eda..49785afe 100644 --- a/awesome.c +++ b/awesome.c @@ -207,6 +207,15 @@ exit_on_signal(EV_P_ ev_signal *w, int revents) ev_unloop(EV_A_ 1); } +/** Function to restart aweome on some signals. + * \param sig the signam received, unused + */ +static void +restart_on_signal(EV_P_ ev_signal *w, int revents) +{ + ewmh_restart(); +} + /** \brief awesome xerror function. * There's no way to check accesses to destroyed windows, thus those cases are * ignored (especially on UnmapNotify's). Other types of errors call Xlibs @@ -336,8 +345,8 @@ main(int argc, char **argv) /* register function for signals */ ev_signal_init(&sigint, exit_on_signal, SIGINT); - ev_signal_init(&sigterm, &exit_on_signal, SIGTERM); - ev_signal_init(&sighup, &exit_on_signal, SIGHUP); + ev_signal_init(&sigterm, exit_on_signal, SIGTERM); + ev_signal_init(&sighup, restart_on_signal, SIGHUP); ev_signal_start(globalconf.loop, &sigint); ev_signal_start(globalconf.loop, &sigterm); ev_signal_start(globalconf.loop, &sighup); diff --git a/ewmh.c b/ewmh.c index 4fd9b843..12d308bb 100644 --- a/ewmh.c +++ b/ewmh.c @@ -555,4 +555,21 @@ ewmh_get_window_icon(xcb_window_t w) return icon; } +/** + * Restart awesome. + */ +void +ewmh_restart(void) +{ + client_t *c; + + for(c = globalconf.clients; c; c = c->next) + client_unban(c); + + xcb_aux_sync(globalconf.connection); + xcb_disconnect(globalconf.connection); + + a_exec(globalconf.argv); +} + // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/ewmh.h b/ewmh.h index f7117b11..7d36d619 100644 --- a/ewmh.h +++ b/ewmh.h @@ -42,6 +42,7 @@ void ewmh_update_net_client_list_stacking(int); void ewmh_check_client_hints(client_t *); void ewmh_update_workarea(int); netwm_icon_t * ewmh_get_window_icon(xcb_window_t); +void ewmh_restart(void); #endif // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/lua.c b/lua.c index cbf00ac9..2907db16 100644 --- a/lua.c +++ b/lua.c @@ -122,15 +122,7 @@ luaA_exec(lua_State *L) static int luaA_restart(lua_State *L __attribute__ ((unused))) { - client_t *c; - - for(c = globalconf.clients; c; c = c->next) - client_unban(c); - - xcb_aux_sync(globalconf.connection); - xcb_disconnect(globalconf.connection); - - a_exec(globalconf.argv); + ewmh_restart(); return 0; }