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

Copyright | (c) Jan Vornberger 2009
License | BSD3-style (see LICENSE)
Maintainer | Adam Vogt <vogt.adam@gmail.com>
Stability | unstable
Portability | unportable
Safe Haskell | Safe-Inferred
Language | Haskell2010

XMonad.Util.Replace

Contents

- Usage
- Notes
  - Implementing a `--replace` flag

Description

Implements a `--replace` behavior outside of core.

Synopsis

- replace :: IO ()

# Usage

You must run the `replace` action before starting xmonad proper, this results in xmonad replacing the currently running WM regardless of the arguments it is run with:

    import XMonad
    import XMonad.Util.Replace
    main = do
       replace
       xmonad $ def { .... }

replace :: IO () #

`replace` must be run before xmonad starts to signals to compliant window managers that they must exit and let xmonad take over.

# Notes

This doesn't seem to work for replacing WMs that have been started from within xmonad, such as with ``restart` "openbox" False`, but no other WMs that implements --replace manage this either. `replace` works for replacing metacity when the full gnome-session is started at least.

## Implementing a `--replace` flag

You can use `getArgs` to watch for an explicit `--replace` flag:

    import XMonad
    import XMonad.Util.Replace (replace)
    import Control.Monad (when)
    import System.Environment (getArgs)

    main = do
       args <- getArgs
       when ("--replace" `elem` args) replace
       xmonad $ def { .... }

Note that your `~/.xmonad/xmonad-$arch-$os` binary is not run with the same flags as the `xmonad` binary that calls it. You may be able to work around this by running your `~/.xmonad/xmonad-$arch-$os` binary directly, which is otherwise not recommended.