From 623a6320e20b53ef302dbb827e6045756f236b52 Mon Sep 17 00:00:00 2001 From: "Travis B. Hartwell" Date: Mon, 27 Oct 2008 01:55:23 +0100 Subject: generic menu and window bringer darcs-hash:20081027005523-c78c1-4de3783ba078b1acd99f70f675c37341030b3d7c.gz --- XMonad/Util/Dmenu.hs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'XMonad/Util/Dmenu.hs') diff --git a/XMonad/Util/Dmenu.hs b/XMonad/Util/Dmenu.hs index ad0ccfc..8a8dc08 100644 --- a/XMonad/Util/Dmenu.hs +++ b/XMonad/Util/Dmenu.hs @@ -15,10 +15,10 @@ ----------------------------------------------------------------------------- module XMonad.Util.Dmenu ( - -- * Usage - -- $usage - dmenu, dmenuXinerama, dmenuMap - ) where + -- * Usage + -- $usage + dmenu, dmenuXinerama, dmenuMap, menu, menuMap + ) where import XMonad import qualified XMonad.StackSet as W @@ -40,9 +40,17 @@ dmenuXinerama opts = do io $ runProcessWithInput "dmenu" ["-xs", show (curscreen+1)] (unlines opts) dmenu :: [String] -> X String -dmenu opts = io $ runProcessWithInput "dmenu" [] (unlines opts) +dmenu opts = menu "dmenu" opts -dmenuMap :: M.Map String a -> X (Maybe a) -dmenuMap selectionMap = do - selection <- dmenu (M.keys selectionMap) +menu :: String -> [String] -> X String +menu menuCmd opts = io $ runProcessWithInput menuCmd [] (unlines opts) + +menuMap :: String -> M.Map String a -> X (Maybe a) +menuMap menuCmd selectionMap = do + selection <- menuFunction (M.keys selectionMap) return $ M.lookup selection selectionMap + where + menuFunction = menu menuCmd + +dmenuMap :: M.Map String a -> X (Maybe a) +dmenuMap selectionMap = menuMap "dmenu" selectionMap \ No newline at end of file -- cgit v1.2.3