xmonad-contrib-0.17.1: Community-maintained extensions for xmonad

Copyright | (c) 2020 Leon Kowarschick
License | BSD3-style (see LICENSE)
Maintainer | Leon Kowarschick. <thereal.elkowar@gmail.com>
Stability | unstable
Portability | unportable
Safe Haskell | Safe-Inferred
Language | Haskell2010

XMonad.Util.ActionCycle

Contents

- Usage

Description

This module provides a way to have "cycling" actions. This means that you can define an `X ()` action that cycles through a list of actions, advancing every time it is executed. This may for exapmle be useful for toggle-style keybindings.

Synopsis

- cycleAction :: String -> [X ()] -> X ()
- cycleActionWithResult :: String -> NonEmpty (X a) -> X a

# Usage

You can use this module to implement cycling key-bindings by importing `ActionCycle`

    import XMonad.Util.ActionCycle

and then creating a keybinding as follows:

    ((mod1Mask, xK_t), cycleAction "cycleActions" [ spawn "commmand1", spawn "command2", spawn "command3" ])

Note that the name given to cycleAction must be a unique action per cycle.

cycleAction Source #

Arguments

:: String | Unique name for this action. May be any arbitrary, unique string.
-> [X ()] | List of actions that will be cycled through.
-> X () |

Generate an `X ()` action that cycles through a list of actions, advancing every time the action is called.

cycleActionWithResult Source #

Arguments

:: String | Unique name for this action. May be any arbitrary, unique string.
-> NonEmpty (X a) | Non-empty List of actions that will be cycled through.
-> X a |

Another version of `cycleAction` that returns the result of the actions. To allow for this, we must make sure that the list of actions is non-empty.