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

Copyright | (c) Yecine Megdiche <yecine.megdiche@gmail.com>
License | BSD3-style (see LICENSE)
Maintainer | Yecine Megdiche <yecine.megdiche@gmail.com>
Stability | unstable
Portability | unportable
Safe Haskell | None
Language | Haskell2010

XMonad.Layout.FixedAspectRatio

Contents

- Usage

Description

Layout modifier for user provided per-window aspect ratios.

Synopsis

- fixedAspectRatio :: (Double, Double) -> l a -> ModifiedLayout FixedAspectRatio l a
- data FixedAspectRatio a
- data ManageAspectRatio
  - = FixRatio Rational Window
  - | ResetRatio Window
  - | ToggleRatio Rational Window
- doFixAspect :: Rational -> ManageHook

# Usage

You can use this module with the following in your `xmonad.hs`:

    import XMonad.Layout.FixedAspectRatio

Then add it to your layout:

    myLayout = fixedAspectRatio (0.5, 0.5) $ Tall 1 (3/100) (1/2)  ||| Full ||| etc..
    main = xmonad def { layoutHook = myLayout }

Which will center the (eventually) shrinked windows in their assigned rectangle.

For a layout modifier that automatically sets the aspect ratio depending on the size hints (for example for programs like mpv), see XMonad.Layout.LayoutHints

See the tutorial and XMonad.Doc.Extending for more info on the `layoutHook`.

You also want to add keybindings to set and clear the aspect ratio:

         -- Set the aspect ratio of the focused window to 16:9
      ,((modm, xK_a), withFocused $ sendMessage . FixRatio (16 / 9))

         -- Clear the aspect ratio from the focused window
      ,((modm .|. shiftMask, xK_a), withFocused $ sendMessage . ResetRatio)

There's one caveat: to keep the usage of the modifier simple, it doesn't remove a window from its cache automatically. Which means that if you close a program window that has some fixed aspect ratios and relaunch it, sometimes it'll still have the fixed aspect ratio. You can try to avoid this by changing they keybinding used to kill the window:

     , ((modMask .|. shiftMask, xK_c), withFocused (sendMessage . ResetRatio) >> kill)

See the tutorial for more info on customizing the keybindings.

This layout also comes with a `ManageHook` `doFixAspect` to automatically fix the aspect ratio:

    myManageHook = composeOne [
      title =? "Netflix" <||> className =? "vlc" --> doFixAspect (16 / 9)
      ...
    ]

Check the tutorial and XMonad.Doc.Extending for more information on customizing the manage hook.

fixedAspectRatio :: (Double, Double) -> l a -> ModifiedLayout FixedAspectRatio l a Source #

Similar to `layoutHintsWithReplacement`, but relies on the user to provide the ratio for each window. `aspectRatio (rx, ry) layout` will adapt the sizes of a layout's windows according to the provided aspect ratio, and position them inside their originally assigned area according to the `rx` and `ry` parameters. (0, 0) places the window at the top left, (1, 0) at the top right, (0.5, 0.5) at the center, etc.

data FixedAspectRatio a Source #

#### Instances

Instances details

LayoutModifier FixedAspectRatio Window Source # |

Instance details

Defined in XMonad.Layout.FixedAspectRatio

Methods

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

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

handleMess :: FixedAspectRatio Window -> SomeMessage -> X (Maybe (FixedAspectRatio Window)) Source #

handleMessOrMaybeModifyIt :: FixedAspectRatio Window -> SomeMessage -> X (Maybe (Either (FixedAspectRatio Window) SomeMessage)) Source #

pureMess :: FixedAspectRatio Window -> SomeMessage -> Maybe (FixedAspectRatio Window) Source #

redoLayout :: FixedAspectRatio Window -> Rectangle -> Maybe (Stack Window) -> [(Window, Rectangle)] -> X ([(Window, Rectangle)], Maybe (FixedAspectRatio Window)) Source #

pureModifier :: FixedAspectRatio Window -> Rectangle -> Maybe (Stack Window) -> [(Window, Rectangle)] -> ([(Window, Rectangle)], Maybe (FixedAspectRatio Window)) Source #

hook :: FixedAspectRatio Window -> X () Source #

unhook :: FixedAspectRatio Window -> X () Source #

modifierDescription :: FixedAspectRatio Window -> String Source #

modifyDescription :: LayoutClass l Window => FixedAspectRatio Window -> l Window -> String Source #

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

data ManageAspectRatio Source #

Constructors

FixRatio Rational Window | Set the aspect ratio for the window
ResetRatio Window | Remove the aspect ratio for the window
ToggleRatio Rational Window | Toggle the reatio

#### Instances

Instances details

Message ManageAspectRatio Source # |
Instance details Defined in XMonad.Layout.FixedAspectRatio

doFixAspect Source #

Arguments

:: Rational | The aspect ratio
-> ManageHook |

A `ManageHook` to set the aspect ratio for newly spawned windows