aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad/Prompt/Layout.hs
diff options
context:
space:
mode:
authorDavid Roundy <droundy@darcs.net>2007-11-11 20:50:36 +0100
committerDavid Roundy <droundy@darcs.net>2007-11-11 20:50:36 +0100
commitf6a589c128a45ec862b704ba5d02a7bc91deae2b (patch)
tree4e8eeb3822b4bc879f074ab83f81912d405fff0f /XMonad/Prompt/Layout.hs
parent3352241c8cfe40428742ca6829ea427498f949e5 (diff)
downloadXMonadContrib-f6a589c128a45ec862b704ba5d02a7bc91deae2b.tar.gz
XMonadContrib-f6a589c128a45ec862b704ba5d02a7bc91deae2b.tar.xz
XMonadContrib-f6a589c128a45ec862b704ba5d02a7bc91deae2b.zip
add two new modules, one to name layouts, another to select a layout.
The latter is pretty useless, as there's no way to find out what layouts are available, but it can at least allow you to select between any layouts that you happen to be using already (in one workspace or another). The former is handy any time you'd rather have a short name for a layout (either for selecting, or for viewing in a status bar). darcs-hash:20071111195036-72aca-8ffbd496a9dbbdd7ca7e92a5bbedb568b2384485.gz
Diffstat (limited to '')
-rw-r--r--XMonad/Prompt/Layout.hs54
1 files changed, 54 insertions, 0 deletions
diff --git a/XMonad/Prompt/Layout.hs b/XMonad/Prompt/Layout.hs
new file mode 100644
index 0000000..6a79a7e
--- /dev/null
+++ b/XMonad/Prompt/Layout.hs
@@ -0,0 +1,54 @@
+-----------------------------------------------------------------------------
+-- |
+-- Module : XMonad.Prompt.Layout
+-- Copyright : (C) 2007 Andrea Rossato, David Roundy
+-- License : BSD3
+--
+-- Maintainer : droundy@darcs.net
+-- Stability : unstable
+-- Portability : unportable
+--
+-- A layout-selection prompt for XMonad
+--
+-----------------------------------------------------------------------------
+
+module XMonad.Prompt.Layout (
+ -- * Usage
+ -- $usage
+ layoutPrompt
+ ) where
+
+import Control.Monad.State ( gets )
+import Data.List ( sort, nub )
+import XMonad hiding ( workspaces )
+import XMonad.Operations ( sendMessage )
+import XMonad.Prompt
+import XMonad.StackSet ( workspaces, layout )
+import XMonad.Layout.LayoutCombinators ( JumpToLayout(..) )
+
+-- $usage
+-- You can use this module with the following in your Config.hs file:
+--
+-- > import XMonad.Prompt.Layout
+--
+-- > , ((modMask .|. shiftMask, xK_m ), layoutPrompt defaultXPConfig)
+
+-- WARNING: This prompt won't display all possible layouts, because the
+-- code to enable this was rejected from xmonad core. It only displays
+-- layouts that are actually in use. Also, you can only select layouts if
+-- you are using NewSelect, rather than the Select defined in xmonad core
+-- (which doesn't have this feature). So all in all, this module is really
+-- more a proof-of-principle than something you can actually use
+-- productively.
+
+data Wor = Wor String
+
+instance XPrompt Wor where
+ showXPrompt (Wor x) = x
+
+layoutPrompt :: XPConfig -> X ()
+layoutPrompt c = do ls <- gets (map (description . layout) . workspaces . windowset)
+ mkXPrompt (Wor "") c (mkCompl $ sort $ nub ls) (sendMessage . JumpToLayout)
+
+mkCompl :: [String] -> String -> IO [String]
+mkCompl l s = return $ filter (\x -> take (length s) x == s) l