XMonad.Hooks.ToggleHook

xmonad-contrib-0.13: Third party extensions for xmonad

Copyright | Ben Boeckel <mathstuf@gmail.com>
License | BSD-style (see LICENSE)
Maintainer | Ben Boeckel <mathstuf@gmail.com>
Stability | unstable
Portability | unportable
Safe Haskell | None
Language | Haskell98

XMonad.Hooks.ToggleHook

Contents

- Usage
- The hook
- Actions
- Queries
- `DynamicLog` utilities

Description

Hook and keybindings for toggling hook behavior.

Synopsis

- toggleHook :: String -> ManageHook -> ManageHook
- toggleHook' :: String -> ManageHook -> ManageHook -> ManageHook
- hookNext :: String -> Bool -> X ()
- toggleHookNext :: String -> X ()
- hookAllNew :: String -> Bool -> X ()
- toggleHookAllNew :: String -> X ()
- willHook :: String -> X Bool
- willHookNext :: String -> X Bool
- willHookAllNew :: String -> X Bool
- willHookNextPP :: String -> (String -> String) -> X (Maybe String)
- willHookAllNewPP :: String -> (String -> String) -> X (Maybe String)
- runLogHook :: X ()

# Usage

This module provides actions (that can be set as keybindings) to be able to cause hooks to be occur on a conditional basis.

You can use it by including the following in your `~/.xmonad/xmonad.hs`:

    import XMonad.Hooks.ToggleHook

and adding 'toggleHook name hook' to your `ManageHook` where `name` is the name of the hook and `hook` is the hook to execute based on the state.

    myManageHook = toggleHook "float" doFloat <+> manageHook def

Additionally, toggleHook' is provided to toggle between two hooks (rather than on/off).

    myManageHook = toggleHook' "oldfocus" (const id) W.focusWindow <+> manageHook def

The `hookNext` and `toggleHookNext` functions can be used in key bindings to set whether the hook is applied or not.

    , ((modm, xK_e), toggleHookNext "float")

`hookAllNew` and `toggleHookAllNew` are similar but float all spawned windows until disabled again.

    , ((modm, xK_r), toggleHookAllNew "float")

# The hook

toggleHook :: String -> ManageHook -> ManageHook #

This `ManageHook` will selectively apply a hook as set by `hookNext` and `hookAllNew`.

toggleHook' :: String -> ManageHook -> ManageHook -> ManageHook #

# Actions

hookNext :: String -> Bool -> X () #

`hookNext name True` arranges for the next spawned window to have the hook `name` applied, `hookNext name False` cancels it.

toggleHookNext :: String -> X () #

hookAllNew :: String -> Bool -> X () #

`hookAllNew name True` arranges for new windows to have the hook `name` applied, `hookAllNew name False` cancels it

toggleHookAllNew :: String -> X () #

# Queries

willHook :: String -> X Bool #

Query what will happen at the next ManageHook call for the hook `name`.

willHookNext :: String -> X Bool #

Whether the next window will trigger the hook `name`.

willHookAllNew :: String -> X Bool #

Whether new windows will trigger the hook `name`.

# `DynamicLog` utilities

The following functions are used to display the current state of `hookNext` and `hookAllNew` in your `dynamicLogWithPP`. `willHookNextPP` and `willHookAllNewPP` should be added to the `ppExtras` field of your `PP`.

Use `runLogHook` to refresh the output of your `logHook`, so that the effects of a `hookNext`/... will be visible immediately:

    , ((modm, xK_e), toggleHookNext "float" >> runLogHook)

The `String -> String` parameters to `willHookNextPP` and `willHookAllNewPP` will be applied to their output, you can use them to set the text color, etc., or you can just pass them `id`.

willHookNextPP :: String -> (String -> String) -> X (Maybe String) #

willHookAllNewPP :: String -> (String -> String) -> X (Maybe String) #

runLogHook :: X () #