XMonad.Util.NamedScratchpad

xmonad-contrib-0.12: Third party extensions for xmonad

Copyright | (c) Konstantin Sobolev <konstantin.sobolev@gmail.com>
License | BSD-style (see LICENSE)
Maintainer | Konstantin Sobolev <konstantin.sobolev@gmail.com>
Stability | unstable
Portability | unportable
Safe Haskell | None
Language | Haskell98

XMonad.Util.NamedScratchpad

Contents

- Usage

Description

Named scratchpads that support several arbitrary applications at the same time.

Synopsis

- data NamedScratchpad = NS {
  - name :: String
  - cmd :: String
  - query :: Query Bool
  - hook :: ManageHook
  }
- nonFloating :: ManageHook
- defaultFloating :: ManageHook
- customFloating :: RationalRect -> ManageHook
- type NamedScratchpads = [NamedScratchpad]
- namedScratchpadAction :: NamedScratchpads -> String -> X ()
- allNamedScratchpadAction :: NamedScratchpads -> String -> X ()
- namedScratchpadManageHook :: NamedScratchpads -> ManageHook
- namedScratchpadFilterOutWorkspace :: [WindowSpace] -> [WindowSpace]
- namedScratchpadFilterOutWorkspacePP :: PP -> PP

# Usage

Allows to have several floating scratchpads running different applications. Bind a key to `namedScratchpadSpawnAction`. Pressing it will spawn configured application, or bring it to the current workspace if it already exists. Pressing the key with the application on the current workspace will send it to a hidden workspace called `NSP`.

If you already have a workspace called `NSP`, it will use that. `NSP` will also appear in xmobar and dzen status bars. You can tweak your `dynamicLog` settings to filter it out if you like.

Create named scratchpads configuration in your xmonad.hs like this:

    import XMonad.StackSet as W
    import XMonad.ManageHook
    import XMonad.Util.NamedScratchpad

    scratchpads = [
    -- run htop in xterm, find it by title, use default floating window placement
        NS "htop" "xterm -e htop" (title =? "htop") defaultFloating ,

    -- run stardict, find it by class name, place it in the floating window
    -- 1/6 of screen width from the left, 1/6 of screen height
    -- from the top, 2/3 of screen width by 2/3 of screen height
        NS "stardict" "stardict" (className =? "Stardict")
            (customFloating $ W.RationalRect (1/6) (1/6) (2/3) (2/3)) ,

    -- run gvim, find by role, don't float
        NS "notes" "gvim --role notes ~/notes.txt" (role =? "notes") nonFloating
    ] where role = stringProperty "WM_WINDOW_ROLE"

Add keybindings:

     , ((modm .|. controlMask .|. shiftMask, xK_t), namedScratchpadAction scratchpads "htop")
     , ((modm .|. controlMask .|. shiftMask, xK_s), namedScratchpadAction scratchpads "stardict")
     , ((modm .|. controlMask .|. shiftMask, xK_n), namedScratchpadAction scratchpads "notes")

... and a manage hook:

     , manageHook = namedScratchpadManageHook scratchpads

For detailed instruction on editing the key binding see XMonad.Doc.Extending

data NamedScratchpad

Single named scratchpad configuration

Constructors

NS |
Fields name :: String Scratchpad name cmd :: String Command used to run application query :: Query Bool Query to find already running application hook :: ManageHook Manage hook called for application window, use it to define the placement. See `nonFloating`, `defaultFloating` and `customFloating`

nonFloating :: ManageHook

Manage hook that makes the window non-floating

defaultFloating :: ManageHook

Manage hook that makes the window floating with the default placement

customFloating :: RationalRect -> ManageHook

Manage hook that makes the window floating with custom placement

type NamedScratchpads = [NamedScratchpad]

Named scratchpads configuration

namedScratchpadAction

Arguments

:: NamedScratchpads | Named scratchpads configuration
-> String | Scratchpad name
-> X () |

Action to pop up specified named scratchpad

allNamedScratchpadAction :: NamedScratchpads -> String -> X ()

namedScratchpadManageHook

Arguments

:: NamedScratchpads | Named scratchpads configuration
-> ManageHook |

Manage hook to use with named scratchpads

namedScratchpadFilterOutWorkspace :: [WindowSpace] -> [WindowSpace]

Transforms a workspace list containing the NSP workspace into one that doesn't contain it. Intended for use with logHooks.

namedScratchpadFilterOutWorkspacePP :: PP -> PP

Transforms a pretty-printer into one not displaying the NSP workspace.

A simple use could be:

    logHook = dynamicLogWithPP . namedScratchpadFilterOutWorkspace $ def

Here is another example, when using XMonad.Layout.IndependentScreens. If you have handles `hLeft` and `hRight` for bars on the left and right screens, respectively, and `pp` is a pretty-printer function that takes a handle, you could write

    logHook = let log screen handle = dynamicLogWithPP . namedScratchpadFilterOutWorkspacePP . marshallPP screen . pp $ handle
              in log 0 hLeft >> log 1 hRight