aboutsummaryrefslogtreecommitdiffstats
path: root/DirectoryPrompt.hs
diff options
context:
space:
mode:
authorDavid Roundy <droundy@darcs.net>2007-08-14 21:11:03 +0200
committerDavid Roundy <droundy@darcs.net>2007-08-14 21:11:03 +0200
commit450717ef44ff3ff06c0bc228acd1547e33b72d36 (patch)
treed5e021caa477f920b5bef370cac3f4704a2a805a /DirectoryPrompt.hs
parent03f5d93ba1d2a0488468186f61b300d3621b3c79 (diff)
downloadXMonadContrib-450717ef44ff3ff06c0bc228acd1547e33b72d36.tar.gz
XMonadContrib-450717ef44ff3ff06c0bc228acd1547e33b72d36.tar.xz
XMonadContrib-450717ef44ff3ff06c0bc228acd1547e33b72d36.zip
use XPrompt in WorkspaceDir.
darcs-hash:20070814191103-72aca-dfa6265cb6f55918e7f66f856fb7e60ac22b42cd.gz
Diffstat (limited to 'DirectoryPrompt.hs')
-rw-r--r--DirectoryPrompt.hs59
1 files changed, 59 insertions, 0 deletions
diff --git a/DirectoryPrompt.hs b/DirectoryPrompt.hs
new file mode 100644
index 0000000..954180c
--- /dev/null
+++ b/DirectoryPrompt.hs
@@ -0,0 +1,59 @@
+-----------------------------------------------------------------------------
+-- |
+-- Module : XMonadContrib.DirectoryPrompt
+-- Copyright : (C) 2007 Andrea Rossato, David Roundy
+-- License : BSD3
+--
+-- Maintainer : droundy@darcs.net
+-- Stability : unstable
+-- Portability : unportable
+--
+-- A directory prompt for XMonad
+--
+-----------------------------------------------------------------------------
+
+module XMonadContrib.DirectoryPrompt (
+ -- * Usage
+ -- $usage
+ directoryPrompt
+ ) where
+
+import XMonad
+import XMonadContrib.XPrompt
+import XMonadContrib.Dmenu ( runProcessWithInput )
+
+-- $usage
+--
+-- 1. In xmonad.cabal change:
+--
+-- > build-depends: base>=2.0, X11>=1.2.1, X11-extras>=0.2, mtl>=1.0, unix>=1.0
+--
+-- to
+--
+-- > build-depends: base>=2.0, X11>=1.2.1, X11-extras>=0.2, mtl>=1.0, unix>=1.0, readline >= 1.0
+--
+-- 2. In Config.hs add:
+--
+-- > import XMonadContrib.XPrompt
+-- > import XMonadContrib.ShellPrompt
+--
+-- 3. In your keybindings add something like:
+--
+-- > , ((modMask .|. controlMask, xK_x), shellPrompt defaultXPConfig)
+--
+
+data Dir = Dir String
+
+instance XPrompt Dir where
+ showXPrompt (Dir x) = x
+
+directoryPrompt :: XPConfig -> String -> (String -> X ()) -> X ()
+directoryPrompt c prom job = mkXPrompt (Dir prom) c getDirCompl job
+
+getDirCompl :: String -> IO [String]
+getDirCompl s = (filter notboring . lines) `fmap`
+ runProcessWithInput "/bin/bash" [] ("compgen -A directory " ++ s ++ "\n")
+
+notboring ('.':'.':_) = True
+notboring ('.':_) = False
+notboring _ = True