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

Copyright | (c) 2021 Tomáš Janoušek <tomi@nomi.cz>
License | BSD3
Maintainer | Tomáš Janoušek <tomi@nomi.cz>
Safe Haskell | Safe-Inferred
Language | Haskell2010

XMonad.Hooks.Rescreen

Contents

- Usage

Description

Custom hooks for screen (xrandr) configuration changes.

Synopsis

- addAfterRescreenHook :: X () -> XConfig l -> XConfig l
- addRandrChangeHook :: X () -> XConfig l -> XConfig l
- data RescreenConfig = RescreenConfig {
  - afterRescreenHook :: X ()
  - randrChangeHook :: X ()
  }
- rescreenHook :: RescreenConfig -> XConfig l -> XConfig l

# Usage

This module provides a replacement for the screen configuration change handling in core that enables attaching custom hooks to screen (xrandr) configuration change events. These can be used to restart/reposition status bars or systrays automatically after xrandr (`dynamicSBs` uses this module internally), as well as to actually invoke xrandr or autorandr when an output is (dis)connected.

To use this, include the following in your `~/.xmonad/xmonad.hs`:

    import XMonad.Hooks.Rescreen

define your custom hooks:

    myAfterRescreenHook :: X ()
    myAfterRescreenHook = spawn "fbsetroot -solid red"

    myRandrChangeHook :: X ()
    myRandrChangeHook = spawn "autorandr --change"

and hook them into your `xmonad` config:

    main = xmonad $ …
                  . addAfterRescreenHook myAfterRescreenHook
                  . addRandrChangeHook myRandrChangeHook
                  . …
                  $ def{…}

See documentation of `rescreenHook` for details about when these hooks are called.

addAfterRescreenHook :: X () -> XConfig l -> XConfig l Source #

Shortcut for `rescreenHook`.

addRandrChangeHook :: X () -> XConfig l -> XConfig l Source #

Shortcut for `rescreenHook`.

data RescreenConfig Source #

Hook configuration for `rescreenHook`.

Constructors

RescreenConfig |

Fields

- afterRescreenHook :: X ()

  hook to invoke after `rescreen`

- randrChangeHook :: X ()

  hook for other randr changes, e.g. (dis)connects

#### Instances

Instances details

Monoid RescreenConfig Source # |
Instance details Defined in XMonad.Hooks.Rescreen Methods mempty :: RescreenConfig Source # mappend :: RescreenConfig -> RescreenConfig -> RescreenConfig Source # mconcat :: [RescreenConfig] -> RescreenConfig Source #
Semigroup RescreenConfig Source # |
Instance details Defined in XMonad.Hooks.Rescreen Methods (<>) :: RescreenConfig -> RescreenConfig -> RescreenConfig Source # sconcat :: NonEmpty RescreenConfig -> RescreenConfig Source # stimes :: Integral b => b -> RescreenConfig -> RescreenConfig Source #
Default RescreenConfig Source # |
Instance details Defined in XMonad.Hooks.Rescreen Methods def :: RescreenConfig #

rescreenHook :: RescreenConfig -> XConfig l -> XConfig l Source #

Attach custom hooks to screen (xrandr) configuration change events. Replaces the built-in rescreen handling of xmonad core with:

1. listen to `RRScreenChangeNotifyEvent` in addition to `ConfigureEvent` on the root window
2. whenever such event is received:
3. clear any other similar events (Xorg server emits them in bunches)
4. if any event was `ConfigureEvent`, `rescreen` and invoke `afterRescreenHook`
5. if there was no `ConfigureEvent`, invoke `randrChangeHook` only

`afterRescreenHook` is useful for restarting/repositioning status bars and systray.

`randrChangeHook` may be used to automatically trigger xrandr (or perhaps autorandr) when outputs are (dis)connected.

Note that `rescreenHook` is safe to use several times, `rescreen` is still done just once and hooks are invoked in sequence, also just once.