xmonad-contrib-0.17.0.9: Community-maintained extensions for xmonad
CopyrightBruce Forte (2017)
LicenseBSD-style (see LICENSE)
MaintainerBruce Forte
Stabilityunstable
Portabilityunportable
Safe HaskellSafe-Inferred
LanguageHaskell2010

XMonad.Util.ExclusiveScratchpads

Description

Named scratchpads that can be mutually exclusive.

Synopsis

Usage

For this module to work properly, you need to use XMonad.Layout.BoringWindows and XMonad.Layout.Minimize, please refer to the documentation of these modules for more information on how to configure them.

To use this module, put the following in your ~/.xmonad/xmonad.hs:

import XMonad.Utils.ExclusiveScratchpads
import XMonad.ManageHook (title,appName)
import qualified XMonad.StackSet as W

Add exclusive scratchpads, for example:

exclusiveSps = mkXScratchpads [ ("htop",   "urxvt -name htop -e htop", title =? "htop")
                              , ("xclock", "xclock", appName =? "xclock")
                              ] $ customFloating $ W.RationalRect (1/4) (1/4) (1/2) (1/2)

The scratchpads don't have to be exclusive, you can create them like this (see ExclusiveScratchpad):

regularSps   = [ XSP "term" "urxvt -name scratchpad" (appName =? "scratchpad") defaultFloating [] ]

Create a list that contains all your scratchpads like this:

scratchpads = exclusiveSps ++ regularSps

Add the hooks to your managehook (see XMonad.Doc.Extending), eg.:

manageHook = myManageHook <> xScratchpadsManageHook scratchpads

And finally add some keybindings (see XMonad.Doc.Extending):

, ((modMask, xK_h), scratchpadAction scratchpads "htop")
, ((modMask, xK_c), scratchpadAction scratchpads "xclock")
, ((modMask, xK_t), scratchpadAction scratchpads "term")
, ((modMask, xK_h), hideAll scratchpads)

Now you can get your scratchpads by pressing the corresponding keys, if you have the htop scratchpad on your current screen and you fetch the xclock scratchpad then htop gets hidden.

If you move a scratchpad it still gets hidden when you fetch a scratchpad of the same family, to change that behaviour and make windows not exclusive anymore when they get resized or moved add these mouse bindings (see XMonad.Doc.Extending):

    , ((mod4Mask, button1), floatMoveNoexclusive scratchpads)
    , ((mod4Mask, button3), resizeNoexclusive scratchpads)

To reset a moved scratchpad to the original position that you set with its hook, call resetExclusiveSp when it is in focus. For example if you want to extend Mod-Return to reset the placement when a scratchpad is in focus but keep the default behaviour for tiled windows, set these key bindings:

, ((modMask, xK_Return), windows W.swapMaster >> resetExclusiveSp scratchpads)

Note: This is just an example, in general you can add more than two exclusive scratchpads and multiple families of such.

mkXScratchpads Source #

Arguments

:: [(String, String, Query Bool)]

List of (name,cmd,query) of the exclusive scratchpads

-> ManageHook

The common hook that they use

-> ExclusiveScratchpads 

Create ExclusiveScratchpads from [(name,cmd,query)] with a common hook

xScratchpadsManageHook Source #

Arguments

:: ExclusiveScratchpads

List of exclusive scratchpads from which a ManageHook should be generated

-> ManageHook 

Keyboard related

scratchpadAction Source #

Arguments

:: ExclusiveScratchpads

List of exclusive scratchpads

-> String

Name of the scratchpad to toggle

-> X () 

Pop up/hide the scratchpad by name and possibly hide its exclusive

hideAll Source #

Arguments

:: ExclusiveScratchpads

List of exclusive scratchpads

-> X () 

Hide all ExclusiveScratchpads on the current screen

resetExclusiveSp Source #

Arguments

:: ExclusiveScratchpads

List of exclusive scratchpads

-> X () 

If the focused window is a scratchpad, the scratchpad gets reset to the original placement specified with the hook and becomes exclusive again

Mouse related

setNoexclusive Source #

Arguments

:: ExclusiveScratchpads

List of exclusive scratchpads

-> Window

Window which should be made not exclusive anymore

-> X () 

Make a window not exclusive anymore

resizeNoexclusive Source #

Arguments

:: ExclusiveScratchpads

List of exclusive scratchpads

-> Window

Window which should be resized

-> X () 

Resize window, make it not exclusive anymore

floatMoveNoexclusive Source #

Arguments

:: ExclusiveScratchpads

List of exclusive scratchpads

-> Window

Window which should be moved

-> X () 

Float and drag the window, make it not exclusive anymore

Types

data ExclusiveScratchpad Source #

Constructors

XSP 

Fields

Hooks

nonFloating :: ManageHook Source #

Manage hook that makes the window non-floating

defaultFloating :: ManageHook Source #

Manage hook that makes the window floating with the default placement

customFloating Source #

Arguments

:: RationalRect

RationalRect x y w h that specifies relative position, height and width (see XMonad.StackSet)

-> ManageHook 

Manage hook that makes the window floating with custom placement