aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad/Layout/Named.hs
blob: f742acb0880100b9ee5996299de7a6db9e968244 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
{-# LANGUAGE FlexibleContexts, FlexibleInstances, MultiParamTypeClasses #-}

-----------------------------------------------------------------------------
-- |
-- Module      :  XMonad.Layout.Named
-- Copyright   :  (c) David Roundy <droundy@darcs.net>
-- License     :  BSD3-style (see LICENSE)
--
-- Maintainer  :  none
-- Stability   :  unstable
-- Portability :  unportable
--
-- A module for assigning a name to a given layout.
--
-----------------------------------------------------------------------------

module XMonad.Layout.Named
    ( -- * Usage
      -- $usage
      named,
      nameTail
    ) where

import XMonad
import XMonad.Layout.LayoutModifier

-- $usage
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@:
--
-- > import XMonad.Layout.Named
--
-- Then edit your @layoutHook@ by adding the Named layout modifier
-- to some layout:
--
-- > myLayouts = named "real big" Full ||| (nameTail $ named "real big" $ Full) ||| etc..
-- > main = xmonad defaultConfig { layoutHook = myLayouts }
--
-- For more detailed instructions on editing the layoutHook see:
--
-- "XMonad.Doc.Extending#Editing_the_layout_hook"

-- | Rename a layout.
named :: String -> l a -> ModifiedLayout Named l a
named s = ModifiedLayout (Named s)

data Named a = Named String deriving ( Read, Show )

instance LayoutModifier Named a where
    modifyDescription (Named n) _ = n


-- | Remove the first word of the name.
nameTail :: l a -> ModifiedLayout NameTail l a
nameTail = ModifiedLayout NameTail

data NameTail a = NameTail deriving (Read,Show)

instance LayoutModifier NameTail a where
  modifyDescription NameTail i = dropWhile (==' ') $ dropWhile (/=' ') $ description i