xmonad-contrib-0.7: Third party extensions for xmonadContentsIndex
XMonad.Hooks.EventHook
Portabilityunportable
Stabilityunstable
Maintainerandrea.rossato@unibz.it
Contents
Usage
Writing a hook
Description

A layout modifier that implements an event hook at the layout level.

Since it operates at the Workspace level, it will install itself on the first current Workspace and will broadcast a Message to all other Workspaces not to handle events.

Synopsis
class (Read eh, Show eh) => EventHook eh where
handleEvent :: eh -> Event -> X ()
eventHook :: EventHook eh => eh -> l a -> HandleEvent eh l a
data HandleEvent eh l a
Usage

You can use this module with the following in your ~/.xmonad/xmonad.hs:

 import XMonad.Hooks.EventHook

Then edit your layoutHook by adding the eventHook:

 layoutHook = eventHook EventHookExample $ avoidStruts $ simpleTabbed ||| Full ||| etc..

and then:

 main = xmonad defaultConfig { layoutHook = myLayouts }

For more detailed instructions on editing the layoutHook see:

XMonad.Doc.Extending#Editing_the_layout_hook

Writing a hook

Writing a hook is very simple.

This is a basic example to log all events:

 data EventHookExample = EventHookExample deriving ( Show, Read )
 instance EventHook EventHookExample where
     handleEvent _ e = io $ hPutStrLn stderr . show $ e --return ()

This is an EventHook to log mouse button events:

 data EventHookButton = EventHookButton deriving ( Show, Read )
 instance EventHook EventHookButton where
    handleEvent _ (ButtonEvent {ev_window = w}) = do
         io $ hPutStrLn stderr $ "This is a button event on window " ++ (show w)
    handleEvent _ _ = return ()

Obviously you can compose event hooks:

 layoutHook = eventHook EventHookButton $ eventHook EventHookExample $ avoidStruts $ simpleTabbed ||| Full ||| etc..
class (Read eh, Show eh) => EventHook eh where
Methods
handleEvent :: eh -> Event -> X ()
show/hide Instances
EventHook EwmhDesktopsHook
EventHook ServerMode
UrgencyHook h => EventHook (WithUrgencyHook h)
eventHook :: EventHook eh => eh -> l a -> HandleEvent eh l a
data HandleEvent eh l a
show/hide Instances
(EventHook eh, LayoutClass l a) => LayoutClass (HandleEvent eh l) a
(Read eh, Read (l a)) => Read (HandleEvent eh l a)
(Show eh, Show (l a)) => Show (HandleEvent eh l a)
Produced by Haddock version 0.8