Files
xmonad-contrib/DirectoryPrompt.hs
Devin Mullins beaead5256 change Dmenu functions to return IO/X (Maybe String)
dmenu exits with code 1 when you hit Escape, and I wanna create a contrib that
takes advantage of that.

This required changes in four contribs (Commands, DirectoryPrompt, ShellPrompt,
and WorkspaceDir), and might require changes in users' Configs. Also, I'm not
sure some of the changes I made to the client code are very Haskelly. Would
appreciate input there.
2007-10-06 07:09:59 +00:00

46 lines
1.3 KiB
Haskell

-----------------------------------------------------------------------------
-- |
-- 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 Data.Maybe(fromMaybe)
import XMonad
import XMonadContrib.XPrompt
import XMonadContrib.Dmenu ( runProcessWithInput )
-- $usage
-- For an example usage see "XMonadContrib.WorkspaceDir"
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 . fromMaybe "") `fmap`
runProcessWithInput "/bin/bash" [] ("compgen -A directory " ++ s ++ "\n")
notboring :: String -> Bool
notboring ('.':'.':_) = True
notboring ('.':_) = False
notboring _ = True