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

Copyright | (c) Dmitry Bogatov <KAction@gnu.org>
License | BSD
Maintainer | Dmitry Bogatov <KAction@gnu.org>
Stability | unstable
Portability | unportable
Safe Haskell | Safe-Inferred
Language | Haskell2010

XMonad.Util.WindowState

Contents

- Usage

Description

Functions for saving per-window data.

Synopsis

- get :: MonadState s m => m s
- put :: MonadState s m => s -> m ()
- newtype StateQuery s a = StateQuery {
  - getQuery :: Query a
  }
- runStateQuery :: StateQuery s a -> Window -> X a
- catchQuery :: Query a -> Query (Maybe a)

# Usage

This module allow to store state data with some `Window`. It is implemented with XProperties, so resources will be freed when `Window` is destoyed.

This module have advantage over XMonad.Actions.TagWindows in that it hides from you implementation details and provides simple type-safe interface. Main datatype is `StateQuery`, which is simple wrapper around `Query`, which is instance of MonadState, with `put` and `get` are functions to acess data, stored in `Window`.

To save some data in window you probably want to do following: > (runStateQuery (put $ Just value) win) :: X () To retrive it, you can use > (runStateQuery get win) :: X (Maybe YourValueType) `Query` can be promoted to `StateQuery` simply by constructor, and reverse is `getQuery`.

For example, I use it to have all X applications `russian` or `dvorak` layout, but emacs have only `us`, to not screw keybindings. Use your imagination!

get :: MonadState s m => m s Source #

Return the state from the internals of the monad.

put :: MonadState s m => s -> m () Source #

Replace the state inside the monad.

newtype StateQuery s a Source #

Wrapper around `Query` with phantom type `s`, representing state, saved in window.

Constructors

StateQuery |

Fields

- getQuery :: Query a

#### Instances

Instances details

MonadIO (StateQuery s) Source # |
Instance details Defined in XMonad.Util.WindowState Methods liftIO :: IO a -> StateQuery s a Source #
Applicative (StateQuery s) Source # |
Instance details Defined in XMonad.Util.WindowState Methods pure :: a -> StateQuery s a Source # (<*>) :: StateQuery s (a -> b) -> StateQuery s a -> StateQuery s b Source # liftA2 :: (a -> b -> c) -> StateQuery s a -> StateQuery s b -> StateQuery s c Source # (*>) :: StateQuery s a -> StateQuery s b -> StateQuery s b Source # (<*) :: StateQuery s a -> StateQuery s b -> StateQuery s a Source #
Functor (StateQuery s) Source # |
Instance details Defined in XMonad.Util.WindowState Methods fmap :: (a -> b) -> StateQuery s a -> StateQuery s b Source # (<$) :: a -> StateQuery s b -> StateQuery s a Source #
Monad (StateQuery s) Source # |
Instance details Defined in XMonad.Util.WindowState Methods (>>=) :: StateQuery s a -> (a -> StateQuery s b) -> StateQuery s b Source # (>>) :: StateQuery s a -> StateQuery s b -> StateQuery s b Source # return :: a -> StateQuery s a Source #
(Show s, Read s, Typeable s) => MonadState (Maybe s) (StateQuery s) Source # | Instance of MonadState for StateQuery.
Instance details Defined in XMonad.Util.WindowState Methods get :: StateQuery s (Maybe s) Source # put :: Maybe s -> StateQuery s () Source # state :: (Maybe s -> (a, Maybe s)) -> StateQuery s a Source #

runStateQuery :: StateQuery s a -> Window -> X a Source #

Apply `StateQuery` to `Window`.

catchQuery :: Query a -> Query (Maybe a) Source #

Lifted to `Query` version of `catchX`