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

Copyright | (C) -- Brent Yorgey 2018 Yclept Nemo
License | BSD-style (see LICENSE)
Maintainer | <byorgey@gmail.com>
Stability | unstable
Portability | unportable
Safe Haskell | None
Language | Haskell2010

XMonad.Layout.Spacing

Contents

- Usage
- Modify Spacing
- Modify Borders

Description

Add a configurable amount of space around windows.

Note: For space/gaps along edges of the screen see XMonad.Layout.Gaps.

Synopsis

- data Spacing a = Spacing {
  - smartBorder :: Bool
  - screenBorder :: Border
  - screenBorderEnabled :: Bool
  - windowBorder :: Border
  - windowBorderEnabled :: Bool
  }
- spacingRaw :: Bool -> Border -> Bool -> Border -> Bool -> l a -> ModifiedLayout Spacing l a
- spacing :: Int -> l a -> ModifiedLayout Spacing l a
- spacingWithEdge :: Int -> l a -> ModifiedLayout Spacing l a
- smartSpacing :: Int -> l a -> ModifiedLayout Spacing l a
- smartSpacingWithEdge :: Int -> l a -> ModifiedLayout Spacing l a
- data SpacingModifier
  - = ModifySmartBorder (Bool -> Bool)
  - | ModifyScreenBorder (Border -> Border)
  - | ModifyScreenBorderEnabled (Bool -> Bool)
  - | ModifyWindowBorder (Border -> Border)
  - | ModifyWindowBorderEnabled (Bool -> Bool)
- setSmartSpacing :: Bool -> X ()
- setScreenSpacing :: Border -> X ()
- setScreenSpacingEnabled :: Bool -> X ()
- setWindowSpacing :: Border -> X ()
- setWindowSpacingEnabled :: Bool -> X ()
- toggleSmartSpacing :: X ()
- toggleScreenSpacingEnabled :: X ()
- toggleWindowSpacingEnabled :: X ()
- setScreenWindowSpacing :: Integer -> X ()
- incWindowSpacing :: Integer -> X ()
- incScreenSpacing :: Integer -> X ()
- decWindowSpacing :: Integer -> X ()
- decScreenSpacing :: Integer -> X ()
- incScreenWindowSpacing :: Integer -> X ()
- decScreenWindowSpacing :: Integer -> X ()
- data Border = Border {
  - top :: Integer
  - bottom :: Integer
  - right :: Integer
  - left :: Integer
  }
- borderMap :: (Integer -> Integer) -> Border -> Border
- borderIncrementBy :: Integer -> Border -> Border

# Usage

You can use this module by importing it into your `xmonad.hs` file:

    import XMonad.Layout.Spacing

and, for example, modifying your `layoutHook` as follows:

    main :: IO ()
    main = xmonad $ def
      { layoutHook = spacingWithEdge 10 $ myLayoutHook
      }

    myLayoutHook = Full ||| ...

The above would add a 10 pixel gap around windows on all sides, as well as add the same amount of spacing around the edges of the screen. If you only want to add spacing around windows, you can use `spacing` instead.

There is also the `spacingRaw` command, for more fine-grained control. For example:

    layoutHook = spacingRaw True (Border 0 10 10 10) True (Border 10 10 10 10) True
               $ myLayoutHook

Breaking this down, the above would do the following:

- `True`: Enable the `smartBorder` to not apply borders when there is only one window.
- `(Border 0 10 10 10)`: Add a `screenBorder` of 10 pixels in every direction but the top.
- `True`: Enable the `screenBorder`.
- `(Border 10 10 10 10)`: Add a `windowBorder` of 10 pixels in every direction.
- `True`: Enable the `windowBorder`.

Warning: If you also use the `avoidStruts` layout modifier, it must come before any of these modifiers. See the documentation of `avoidStruts` for details.

data Spacing a Source #

A `LayoutModifier` providing customizable screen and window borders. Borders are clamped to `[0,Infinity]` before being applied.

Constructors

Spacing |

Fields

- smartBorder :: Bool

  When `True` borders are not applied if there fewer than two windows.

- screenBorder :: Border

  The screen border.

- screenBorderEnabled :: Bool

  Is the screen border enabled?

- windowBorder :: Border

  The window borders.

- windowBorderEnabled :: Bool

  Is the window border enabled?

#### Instances

Instances details

Eq a => LayoutModifier Spacing a Source # |

Instance details

Defined in XMonad.Layout.Spacing

Methods

modifyLayout :: LayoutClass l a => Spacing a -> Workspace WorkspaceId (l a) a -> Rectangle -> X ([(a, Rectangle)], Maybe (l a)) Source #

modifyLayoutWithUpdate :: LayoutClass l a => Spacing a -> Workspace WorkspaceId (l a) a -> Rectangle -> X (([(a, Rectangle)], Maybe (l a)), Maybe (Spacing a)) Source #

handleMess :: Spacing a -> SomeMessage -> X (Maybe (Spacing a)) Source #

handleMessOrMaybeModifyIt :: Spacing a -> SomeMessage -> X (Maybe (Either (Spacing a) SomeMessage)) Source #

pureMess :: Spacing a -> SomeMessage -> Maybe (Spacing a) Source #

redoLayout :: Spacing a -> Rectangle -> Maybe (Stack a) -> [(a, Rectangle)] -> X ([(a, Rectangle)], Maybe (Spacing a)) Source #

pureModifier :: Spacing a -> Rectangle -> Maybe (Stack a) -> [(a, Rectangle)] -> ([(a, Rectangle)], Maybe (Spacing a)) Source #

hook :: Spacing a -> X () Source #

unhook :: Spacing a -> X () Source #

modifierDescription :: Spacing a -> String Source #

modifyDescription :: LayoutClass l a => Spacing a -> l a -> String Source #

Read (Spacing a) Source # |
Instance details Defined in XMonad.Layout.Spacing Methods readsPrec :: Int -> ReadS (Spacing a) Source # readList :: ReadS [Spacing a] Source # readPrec :: ReadPrec (Spacing a) Source # readListPrec :: ReadPrec [Spacing a] Source #
Show (Spacing a) Source # |
Instance details Defined in XMonad.Layout.Spacing Methods showsPrec :: Int -> Spacing a -> ShowS Source # show :: Spacing a -> String Source # showList :: [Spacing a] -> ShowS Source #

spacingRaw Source #

Arguments

:: Bool | The `smartBorder`.
-> Border | The `screenBorder`.
-> Bool | The `screenBorderEnabled`.
-> Border | The `windowBorder`.
-> Bool | The `windowBorderEnabled`.
-> l a |
-> ModifiedLayout Spacing l a |

Generate the `ModifiedLayout`, exposing all initial state of `Spacing`.

spacing :: Int -> l a -> ModifiedLayout Spacing l a Source #

Surround all windows by a certain number of pixels of blank space. See `spacingRaw`.

spacingWithEdge :: Int -> l a -> ModifiedLayout Spacing l a Source #

Surround all windows by a certain number of pixels of blank space, and additionally adds the same amount of spacing around the edge of the screen. See `spacingRaw`.

smartSpacing :: Int -> l a -> ModifiedLayout Spacing l a Source #

Surrounds all windows with blank space, except when the window is the only visible window on the current workspace. See `spacingRaw`.

smartSpacingWithEdge :: Int -> l a -> ModifiedLayout Spacing l a Source #

Surrounds all windows with blank space, and adds the same amount of spacing around the edge of the screen, except when the window is the only visible window on the current workspace. See `spacingRaw`.

# Modify Spacing

data SpacingModifier Source #

Messages to alter the state of `Spacing` using the endomorphic function arguments.

Constructors

ModifySmartBorder (Bool -> Bool) |
ModifyScreenBorder (Border -> Border) |
ModifyScreenBorderEnabled (Bool -> Bool) |
ModifyWindowBorder (Border -> Border) |
ModifyWindowBorderEnabled (Bool -> Bool) |

#### Instances

Instances details

Message SpacingModifier Source # |
Instance details Defined in XMonad.Layout.Spacing

setSmartSpacing :: Bool -> X () Source #

Set `smartBorder` to the given `Bool`.

setScreenSpacing :: Border -> X () Source #

Set `screenBorder` to the given `Border`.

setScreenSpacingEnabled :: Bool -> X () Source #

Set `screenBorderEnabled` to the given `Bool`.

setWindowSpacing :: Border -> X () Source #

Set `windowBorder` to the given `Border`.

setWindowSpacingEnabled :: Bool -> X () Source #

Set `windowBorderEnabled` to the given `Bool`.

toggleSmartSpacing :: X () Source #

Toggle `smartBorder`.

toggleScreenSpacingEnabled :: X () Source #

Toggle `screenBorderEnabled`.

toggleWindowSpacingEnabled :: X () Source #

Toggle `windowBorderEnabled`.

setScreenWindowSpacing :: Integer -> X () Source #

Set all borders to a uniform size; see `setWindowSpacing` and `setScreenSpacing`.

incWindowSpacing :: Integer -> X () Source #

Increment the borders of `windowBorder` using `borderIncrementBy`, which preserves border ratios during clamping.

incScreenSpacing :: Integer -> X () Source #

Increment the borders of `screenBorder` using `borderIncrementBy`.

decWindowSpacing :: Integer -> X () Source #

Inverse of `incWindowSpacing`, equivalent to applying `negate`.

decScreenSpacing :: Integer -> X () Source #

Inverse of `incScreenSpacing`.

incScreenWindowSpacing :: Integer -> X () Source #

Increment both screen and window borders; see `incWindowSpacing` and `incScreenSpacing`.

decScreenWindowSpacing :: Integer -> X () Source #

Inverse of `incScreenWindowSpacing`.

# Modify Borders

data Border Source #

Represent the borders of a rectangle.

Constructors

Border |

Fields

- top :: Integer
- bottom :: Integer
- right :: Integer
- left :: Integer

#### Instances

Instances details

Read Border Source # |
Instance details Defined in XMonad.Layout.Spacing Methods readsPrec :: Int -> ReadS Border Source # readList :: ReadS [Border] Source # readPrec :: ReadPrec Border Source # readListPrec :: ReadPrec [Border] Source #
Show Border Source # |
Instance details Defined in XMonad.Layout.Spacing Methods showsPrec :: Int -> Border -> ShowS Source # show :: Border -> String Source # showList :: [Border] -> ShowS Source #

borderMap :: (Integer -> Integer) -> Border -> Border Source #

Map a function over a `Border`. That is, over the four individual borders.

borderIncrementBy :: Integer -> Border -> Border Source #

Change the border spacing by the provided amount, adjusted so that at least one border field is `>=0`.