| xmonad-contrib-0.8.1: Third party extensions for xmonad | Source code | Contents | Index

XMonad.Hooks.EventHook

Portability | unportable
Stability | unstable
Maintainer | andrea.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 `Workspace`s 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

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 | Source

Methods

handleEvent :: eh -> Event -> X () | Source

Instances

EventHook EwmhDesktopsHook
EventHook ServerMode
UrgencyHook h => EventHook (WithUrgencyHook h)

eventHook :: EventHook eh => eh -> l a -> HandleEvent eh l a | Source

data HandleEvent eh l a | Source

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 2.4.2