diff --git a/client.c b/client.c index fccefd6d..b4949d45 100644 --- a/client.c +++ b/client.c @@ -666,11 +666,13 @@ client_updatewmhints(client_t *c) if((wmh = xcb_get_wm_hints(globalconf.connection, c->win))) { const uint32_t wm_hints_flags = xcb_wm_hints_get_flags(wmh); - if((c->isurgent = ((wm_hints_flags & XCB_WM_X_URGENCY_HINT) && - globalconf.focus->client != c))) + if((c->isurgent = (wm_hints_flags & XCB_WM_X_URGENCY_HINT))) { widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS); titlebar_draw(c); + /* execute hook */ + luaA_client_userdata_new(c); + luaA_dofunction(globalconf.L, globalconf.hooks.urgent, 1); } if((wm_hints_flags & XCB_WM_STATE_HINT) && (xcb_wm_hints_get_initial_state(wmh) == XCB_WM_WITHDRAWN_STATE)) diff --git a/lua.c b/lua.c index 243eb986..ee8c990c 100644 --- a/lua.c +++ b/lua.c @@ -360,6 +360,20 @@ luaA_hooks_titleupdate(lua_State *L) return 0; } +/** Set the function called when a client get urgency flag. This function is called with + * the client object as argument. + * \param A function to call when a client get the urgent flag. + */ +static int +luaA_hooks_urgent(lua_State *L) +{ + luaA_checkfunction(L, 1); + if(globalconf.hooks.urgent) + luaL_unref(L, LUA_REGISTRYINDEX, globalconf.hooks.urgent); + globalconf.hooks.urgent = luaL_ref(L, LUA_REGISTRYINDEX); + return 0; +} + /** Set default font. * \param A string with a font name in Pango format. */ @@ -439,6 +453,7 @@ luaA_parserc(const char *rcfile) { "mouseover", luaA_hooks_mouseover }, { "arrange", luaA_hooks_arrange }, { "titleupdate", luaA_hooks_titleupdate }, + { "urgent", luaA_hooks_urgent }, { NULL, NULL } }; diff --git a/structs.h b/structs.h index 727bfe0e..222ca97c 100644 --- a/structs.h +++ b/structs.h @@ -429,6 +429,8 @@ struct awesome_t luaA_function arrange; /** Command to run on title change */ luaA_function titleupdate; + /** Command to run on urgent flag */ + luaA_function urgent; } hooks; };