[xmonad] Shutdown hook
Juraj Hercek
juhe_xmonad at hck.sk
Sat Feb 13 19:56:01 EST 2010
On 02/14/2010 12:55 AM, Don Stewart wrote:
> juhe_xmonad:
>
>> Hello,
>>
>> There is a startupHook in XConfig. I'm missing shutdownHook however. Is
>> there any proper way to execute custom code when xmonad is about to exit?
>>
>>
> xmonad exits by throwing an asynchronous exception from the inner loop
> out to main. The runtime catches this an exits gracefully.
>
> You can write your own shutdown hook by catching this exception in your
> config main, and running your hook, before rethrowing.
>
> I bet someone's already done this, and wrapped it up nicely, otherwise,
> look at Control.Exception in the Haskell base library for how to use the
> catch/handle functions.
>
> Pseudocode:
>
> import Control.Exception
> import XMonad
>
> main = handle xmonad shutdown
> where
> shutdown e = do
> ... my action ...
> throw e
>
Thanks for quick response!
-- Juraj
More information about the xmonad
mailing list