Re: [PATCH] 0001-hooks-add-exit-hook
At 1243184445 time_t, Gregor Best wrote: You wouldn't need such a hook. Just append all stuff which needs to be started to the end of your rc.lua Except that it's not very easy to use when you just want to add that code in a module. You can't access rc.lua and telling user to add code ia PITA. Cheers, -- Julien Danjou // ᐰ jul...@danjou.info http://julien.danjou.info // 9A0D 5FD9 EB42 22F6 8974 C95C A462 B51E C2FE E5CD // Don't give up. signature.asc Description: Digital signature
Re: [PATCH] 0001-hooks-add-exit-hook
At 1243177021 time_t, koniu wrote: and the patch :P Pushed. -- Julien Danjou // ᐰ jul...@danjou.info http://julien.danjou.info // 9A0D 5FD9 EB42 22F6 8974 C95C A462 B51E C2FE E5CD // Ferns will rule the world. signature.asc Description: Digital signature
Re: [PATCH] 0001-hooks-add-exit-hook
At Mon, 25 May 2009 11:44:25 +0200 Julien Danjou wrote: At 1243184445 time_t, Gregor Best wrote: You wouldn't need such a hook. Just append all stuff which needs to be started to the end of your rc.lua Except that it's not very easy to use when you just want to add that code in a module. You can't access rc.lua and telling user to add code ia PITA. Cheers, Agreed, I didn't think of that. -- GCS/IT/M d- s+:- a--- C++ UL+++ US UB++ P+++ L+++ E--- W+ N+ o-- K- w--- O M-- V PS+ PE- Y+ PGP+++ t+ 5 X+ R tv+ b++ DI+++ D+++ G+ e- h! r y+ Gregor Best signature.asc Description: PGP signature
[PATCH] 0001-hooks-add-exit-hook
Hey, How about adding a hook that's executed right before awesome exits? This would allow eg. dumping some stuff to a file thus making session saving possible. The proposed patch will run the hooked functions inside awesome_atexit() which also takes effect during awesome restart (including xrandr enabling/rotating screens etc). Unfortunately it won't do anything on ctrl-alt-backsp or xserver crash but I guess that's not really possible. thanks, koniu -- To unsubscribe, send mail to awesome-devel-unsubscr...@naquadah.org.
Re: [PATCH] 0001-hooks-add-exit-hook
and the patch :P From 625468d430714577ae6ec5a87004442ca7348117 Mon Sep 17 00:00:00 2001 From: koniu gkusni...@gmail.com Date: Sat, 23 May 2009 16:56:41 +0100 Subject: [PATCH] hooks: add exit hook Signed-off-by: koniu gkusni...@gmail.com --- awesome.c |5 + hooks.c | 13 + luaa.c|1 + structs.h |2 ++ 4 files changed, 21 insertions(+), 0 deletions(-) diff --git a/awesome.c b/awesome.c index 5035a72..630820b 100644 --- a/awesome.c +++ b/awesome.c @@ -62,6 +62,11 @@ awesome_atexit(void) { int screen_nbr, nscreens; +if(globalconf.hooks.exit != LUA_REFNIL) +{ +luaA_dofunction_from_registry(globalconf.L, globalconf.hooks.exit, 0, 0); +} + a_dbus_cleanup(); /* reparent systray windows, otherwise they may die with their master */ diff --git a/hooks.c b/hooks.c index b2ec266..f124193 100644 --- a/hooks.c +++ b/hooks.c @@ -202,6 +202,18 @@ luaA_hooks_timer(lua_State *L) return 1; } +/** Set the function called on awesome exit + * \param L The Lua VM state. + * \return The number of elements pushed on stack. + * \luastack + * \lparam A function to call on awesome exit. + */ +static int +luaA_hooks_exit(lua_State *L) +{ +HANDLE_HOOK(L, globalconf.hooks.exit); +} + #ifdef WITH_DBUS /** Set the function to be called when a D-Bus event is received. * The first argument passed to this function is the type of the message we @@ -236,6 +248,7 @@ const struct luaL_reg awesome_hooks_lib[] = { tagged, luaA_hooks_tagged }, { startup_notification, luaA_hooks_startup_notification }, { timer, luaA_hooks_timer }, +{ exit, luaA_hooks_exit }, #ifdef WITH_DBUS { dbus, luaA_hooks_dbus }, #endif diff --git a/luaa.c b/luaa.c index 9b5d4c1..9a69743 100644 --- a/luaa.c +++ b/luaa.c @@ -742,6 +742,7 @@ luaA_init(xdgHandle* xdg) globalconf.hooks.property = LUA_REFNIL; globalconf.hooks.startup_notification = LUA_REFNIL; globalconf.hooks.timer = LUA_REFNIL; +globalconf.hooks.exit = LUA_REFNIL; #ifdef WITH_DBUS globalconf.hooks.dbus = LUA_REFNIL; #endif diff --git a/structs.h b/structs.h index 56d4d17..3a11872 100644 --- a/structs.h +++ b/structs.h @@ -120,6 +120,8 @@ struct awesome_t luaA_ref property; /** Command to run on time */ luaA_ref timer; +/** Command to run on awesome exit */ +luaA_ref exit; /** Startup notification hooks */ luaA_ref startup_notification; #ifdef WITH_DBUS -- 1.6.3.1
Re: [PATCH] 0001-hooks-add-exit-hook
Without even judging the idea i wonder, shouldn't an exit hook also mean a startup hook (maybe just for the real start up)? Especially if you want to do session management'ish things. -- To unsubscribe, send mail to awesome-devel-unsubscr...@naquadah.org.
Re: [PATCH] 0001-hooks-add-exit-hook
At Sun, 24 May 2009 18:43:04 +0200 Maarten Maathuis wrote: Without even judging the idea i wonder, shouldn't an exit hook also mean a startup hook (maybe just for the real start up)? Especially if you want to do session management'ish things. You wouldn't need such a hook. Just append all stuff which needs to be started to the end of your rc.lua -- GCS/IT/M d- s+:- a--- C++ UL+++ US UB++ P+++ L+++ E--- W+ N+ o-- K- w--- O M-- V PS+ PE- Y+ PGP+++ t+ 5 X+ R tv+ b++ DI+++ D+++ G+ e- h! r y+ Gregor Best signature.asc Description: PGP signature
Re: [PATCH] 0001-hooks-add-exit-hook
rc.lua is also loaded on awesome restart, i can't imagine that you want to do session management'ish stuff then -- To unsubscribe, send mail to awesome-devel-unsubscr...@naquadah.org.
Re: [PATCH] 0001-hooks-add-exit-hook
At Sun, 24 May 2009 19:11:42 +0200 Maarten Maathuis wrote: rc.lua is also loaded on awesome restart, i can't imagine that you want to do session management'ish stuff then How would awesome then suppress running the startup hook if it is restarted? IIRC it does a full execve on itself, so there's no way of telling the new instance to not run the hook. -- GCS/IT/M d- s+:- a--- C++ UL+++ US UB++ P+++ L+++ E--- W+ N+ o-- K- w--- O M-- V PS+ PE- Y+ PGP+++ t+ 5 X+ R tv+ b++ DI+++ D+++ G+ e- h! r y+ Gregor Best signature.asc Description: PGP signature
Re: [PATCH] 0001-hooks-add-exit-hook
Property on the root window? On Sun, May 24, 2009 at 8:00 PM, Gregor Best farha...@googlemail.com wrote: At Sun, 24 May 2009 19:11:42 +0200 Maarten Maathuis wrote: rc.lua is also loaded on awesome restart, i can't imagine that you want to do session management'ish stuff then How would awesome then suppress running the startup hook if it is restarted? IIRC it does a full execve on itself, so there's no way of telling the new instance to not run the hook. -- GCS/IT/M d- s+:- a--- C++ UL+++ US UB++ P+++ L+++ E--- W+ N+ o-- K- w--- O M-- V PS+ PE- Y+ PGP+++ t+ 5 X+ R tv+ b++ DI+++ D+++ G+ e- h! r y+ Gregor Best -- To unsubscribe, send mail to awesome-devel-unsubscr...@naquadah.org.