XMonad.Hooks.ManageHelpers

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

Copyright | (c) Lukas Mai
License | BSD
Maintainer | Lukas Mai <l.mai@web.de>
Stability | unstable
Portability | unportable
Safe Haskell | None
Language | Haskell2010

XMonad.Hooks.ManageHelpers

Description

This module provides helper functions to be used in `manageHook`. Here's how you might use this:

    import XMonad.Hooks.ManageHelpers
    main =
        xmonad def{
            ...
            manageHook = composeOne [
                isKDETrayWindow -?> doIgnore,
                transience,
                isFullscreen -?> doFullFloat,
                resource =? "stalonetray" -?> doIgnore
            ],
            ...
        }

Here's how you can define more helpers like the ones from this module:

    -- some function you want to transform into an infix operator
    f :: a -> b -> Bool

    -- a new helper
    q ***? x = fmap (\a -> f a x) q   -- or: (\b -> f x b)
    -- or
    q ***? x = fmap (`f` x) q         -- or: (x `f`)

Any existing operator can be "lifted" in the same way:

    q ++? x = fmap (++ x) q

Synopsis

- data Side
  - = SC
  - | NC
  - | CE
  - | CW
  - | SE
  - | SW
  - | NE
  - | NW
  - | C
- composeOne :: (Monoid a, Monad m) => [m (Maybe a)] -> m a
- (-?>) :: (Functor m, Monad m) => m Bool -> m a -> m (Maybe a)
- (/=?) :: (Eq a, Functor m) => m a -> a -> m Bool
- (^?) :: (Eq a, Functor m) => m [a] -> [a] -> m Bool
- (~?) :: (Eq a, Functor m) => m [a] -> [a] -> m Bool
- ($?) :: (Eq a, Functor m) => m [a] -> [a] -> m Bool
- (<==?) :: (Eq a, Functor m) => m a -> a -> m (Match a)
- (</=?) :: (Eq a, Functor m) => m a -> a -> m (Match a)
- (-->>) :: (Monoid b, Monad m) => m (Match a) -> (a -> m b) -> m b
- (-?>>) :: (Functor m, Monad m) => m (Match a) -> (a -> m b) -> m (Maybe b)
- currentWs :: Query WorkspaceId
- windowTag :: Query (Maybe WorkspaceId)
- isInProperty :: String -> String -> Query Bool
- isKDETrayWindow :: Query Bool
- isFullscreen :: Query Bool
- isMinimized :: Query Bool
- isDialog :: Query Bool
- isNotification :: Query Bool
- pid :: Query (Maybe ProcessID)
- desktop :: Query (Maybe Int)
- transientTo :: Query (Maybe Window)
- maybeToDefinite :: (Monoid a, Functor m) => m (Maybe a) -> m a
- type MaybeManageHook = Query (Maybe (Endo WindowSet))
- transience :: MaybeManageHook
- transience' :: ManageHook
- clientLeader :: Query (Maybe Window)
- sameBy :: Eq prop => Query (Maybe prop) -> Query [Window]
- shiftToSame :: Eq prop => Query (Maybe prop) -> MaybeManageHook
- shiftToSame' :: Eq prop => Query (Maybe prop) -> ManageHook
- doRectFloat :: RationalRect -> ManageHook
- doFullFloat :: ManageHook
- doCenterFloat :: ManageHook
- doSideFloat :: Side -> ManageHook
- doFloatAt :: Rational -> Rational -> ManageHook
- doFloatDep :: (RationalRect -> RationalRect) -> ManageHook
- doHideIgnore :: ManageHook
- doSink :: ManageHook
- doLower :: ManageHook
- doRaise :: ManageHook
- doFocus :: ManageHook
- data Match a

# Documentation

data Side #

Denotes a side of a screen. `S` stands for South, `NE` for Northeast etc. `C` stands for Center.

Constructors

SC |
NC |
CE |
CW |
SE |
SW |
NE |
NW |
C |

#### Instances

Instances details

Read Side # |
Instance details Defined in XMonad.Hooks.ManageHelpers Methods readsPrec :: Int -> ReadS Side # readList :: ReadS [Side] # readPrec :: ReadPrec Side # readListPrec :: ReadPrec [Side] #
Show Side # |
Instance details Defined in XMonad.Hooks.ManageHelpers Methods showsPrec :: Int -> Side -> ShowS # show :: Side -> String # showList :: [Side] -> ShowS #
Eq Side # |
Instance details Defined in XMonad.Hooks.ManageHelpers Methods (==) :: Side -> Side -> Bool # (/=) :: Side -> Side -> Bool #

composeOne :: (Monoid a, Monad m) => [m (Maybe a)] -> m a #

An alternative `ManageHook` composer. Unlike `composeAll` it stops as soon as a candidate returns a `Just` value, effectively running only the first match (whereas `composeAll` continues and executes all matching rules).

(-?>) :: (Functor m, Monad m) => m Bool -> m a -> m (Maybe a) infixr 0 #

A helper operator for use in `composeOne`. It takes a condition and an action; if the condition fails, it returns `Nothing` from the `Query` so `composeOne` will go on and try the next rule.

(/=?) :: (Eq a, Functor m) => m a -> a -> m Bool #

q /=? x. if the result of q equals x, return False

(^?) :: (Eq a, Functor m) => m [a] -> [a] -> m Bool #

q ^? x. if the result of `x `isPrefixOf` q`, return True

(~?) :: (Eq a, Functor m) => m [a] -> [a] -> m Bool #

q ~? x. if the result of `x `isInfixOf` q`, return True

($?) :: (Eq a, Functor m) => m [a] -> [a] -> m Bool #

q $? x. if the result of `x `isSuffixOf` q`, return True

(<==?) :: (Eq a, Functor m) => m a -> a -> m (Match a) #

q <==? x. if the result of q equals x, return True grouped with q

(</=?) :: (Eq a, Functor m) => m a -> a -> m (Match a) #

q </=? x. if the result of q notequals x, return True grouped with q

(-->>) :: (Monoid b, Monad m) => m (Match a) -> (a -> m b) -> m b infixr 0 #

A helper operator for use in `composeAll`. It takes a condition and a function taking a grouped datum to action. If `p` is true, it executes the resulting action.

(-?>>) :: (Functor m, Monad m) => m (Match a) -> (a -> m b) -> m (Maybe b) infixr 0 #

A helper operator for use in `composeOne`. It takes a condition and a function taking a groupdatum to action. If `p` is true, it executes the resulting action. If it fails, it returns `Nothing` from the `Query` so `composeOne` will go on and try the next rule.

currentWs :: Query WorkspaceId #

Return the current workspace

windowTag :: Query (Maybe WorkspaceId) #

Return the workspace tag of a window, if already managed

isInProperty :: String -> String -> Query Bool #

Helper to check if a window property contains certain value.

isKDETrayWindow :: Query Bool #

A predicate to check whether a window is a KDE system tray icon.

isFullscreen :: Query Bool #

A predicate to check whether a window wants to fill the whole screen. See also `doFullFloat`.

isMinimized :: Query Bool #

A predicate to check whether a window is hidden (minimized). See also XMonad.Actions.Minimize.

isDialog :: Query Bool #

A predicate to check whether a window is a dialog.

See https://specifications.freedesktop.org/wm-spec/wm-spec-1.5.html#idm46485863906176.

isNotification :: Query Bool #

A predicate to check whether a window is a notification.

See https://specifications.freedesktop.org/wm-spec/wm-spec-1.5.html#idm46485863906176.

pid :: Query (Maybe ProcessID) #

This function returns `Just` the `_NET_WM_PID` property for a particular window if set, `Nothing` otherwise.

See https://specifications.freedesktop.org/wm-spec/wm-spec-1.5.html#idm45623487788432.

desktop :: Query (Maybe Int) #

This function returns `Just` the `_NET_WM_DESKTOP` property for a particular window if set, `Nothing` otherwise.

See https://specifications.freedesktop.org/wm-spec/wm-spec-1.5.html#idm46181547492704.

transientTo :: Query (Maybe Window) #

A predicate to check whether a window is Transient. It holds the result which might be the window it is transient to or it might be `Nothing`.

maybeToDefinite :: (Monoid a, Functor m) => m (Maybe a) -> m a #

converts `MaybeManageHook`s to `ManageHook`s

type MaybeManageHook = Query (Maybe (Endo WindowSet)) #

A ManageHook that may or may not have been executed; the outcome is embedded in the Maybe

transience :: MaybeManageHook #

A convenience `MaybeManageHook` that will check to see if a window is transient, and then move it to its parent.

transience' :: ManageHook #

`transience` set to a `ManageHook`

clientLeader :: Query (Maybe Window) #

This function returns `Just` the `WM_CLIENT_LEADER` property for a particular window if set, `Nothing` otherwise. Note that, generally, the window ID returned from this property (by firefox, for example) corresponds to an unmapped or unmanaged dummy window. For this to be useful in most cases, it should be used together with `sameBy`.

See https://tronche.com/gui/x/icccm/sec-5.html.

sameBy :: Eq prop => Query (Maybe prop) -> Query [Window] #

For a given window, `sameBy` returns all windows that have a matching property (e.g. those obtained from Queries of `clientLeader` and `pid`).

shiftToSame :: Eq prop => Query (Maybe prop) -> MaybeManageHook #

`MaybeManageHook` that moves the window to the same workspace as the first other window that has the same value of a given `Query`. Useful Queries for this include `clientLeader` and `pid`.

shiftToSame' :: Eq prop => Query (Maybe prop) -> ManageHook #

`shiftToSame` set to a `ManageHook`

doRectFloat #

Arguments

:: RationalRect | The rectangle to float the window in. 0 to 1; x, y, w, h.
-> ManageHook |

Floats the new window in the given rectangle.

doFullFloat :: ManageHook #

Floats the window and makes it use the whole screen. Equivalent to ``doRectFloat` $ `RationalRect` 0 0 1 1`.

doCenterFloat :: ManageHook #

Floats a new window with its original size, but centered.

doSideFloat :: Side -> ManageHook #

Floats a new window with its original size on the specified side of a screen

doFloatAt :: Rational -> Rational -> ManageHook #

Floats a new window with its original size, and its top left corner at a specific point on the screen (both coordinates should be in the range 0 to 1).

doFloatDep :: (RationalRect -> RationalRect) -> ManageHook #

Floats a new window using a rectangle computed as a function of the rectangle that it would have used by default.

doHideIgnore :: ManageHook #

Hides window and ignores it.

doSink :: ManageHook #

Sinks a window

doLower :: ManageHook #

Lower an unmanaged window. Useful together with `doIgnore` to lower special windows that for some reason don't do it themselves.

doRaise :: ManageHook #

Raise an unmanaged window. Useful together with `doIgnore` to raise special windows that for some reason don't do it themselves.

doFocus :: ManageHook #

Focus a window (useful in `setActivateHook`).

data Match a #

A grouping type, which can hold the outcome of a predicate Query. This is analogous to group types in regular expressions. TODO: create a better API for aggregating multiple Matches logically