module XMonad.Util.Dmenu (
dmenu, dmenuXinerama, dmenuMap, menu, menuArgs, menuMap, menuMapArgs
) where
import XMonad
import qualified XMonad.StackSet as W
import qualified Data.Map as M
import XMonad.Util.Run
dmenuXinerama :: [String] -> X String
[String]
opts = do
Int
curscreen <-
forall a b. (Integral a, Num b) => a -> b
fromIntegral forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall i l a sid sd. Screen i l a sid sd -> sid
W.screen forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall i l a sid sd. StackSet i l a sid sd -> Screen i l a sid sd
W.current forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
gets XState
-> StackSet String (Layout Window) Window ScreenId ScreenDetail
windowset :: X Int
String
_ <-
forall (m :: * -> *).
MonadIO m =>
String -> [String] -> String -> m String
runProcessWithInput String
"dmenu" [String
"-xs", forall a. Show a => a -> String
show (Int
curscreenforall a. Num a => a -> a -> a
+Int
1)] ([String] -> String
unlines [String]
opts)
forall (m :: * -> *).
MonadIO m =>
String -> [String] -> [String] -> m String
menuArgs String
"dmenu" [String
"-xs", forall a. Show a => a -> String
show (Int
curscreenforall a. Num a => a -> a -> a
+Int
1)] [String]
opts
dmenu :: MonadIO m => [String] -> m String
= forall (m :: * -> *). MonadIO m => String -> [String] -> m String
menu String
"dmenu"
menu :: MonadIO m => String -> [String] -> m String
String
menuCmd = forall (m :: * -> *).
MonadIO m =>
String -> [String] -> [String] -> m String
menuArgs String
menuCmd []
menuArgs :: MonadIO m => String -> [String] -> [String] -> m String
String
menuCmd [String]
args [String]
opts = forall a. (a -> Bool) -> [a] -> [a]
filter (forall a. Eq a => a -> a -> Bool
/=Char
'\n') forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
forall (m :: * -> *).
MonadIO m =>
String -> [String] -> String -> m String
runProcessWithInput String
menuCmd [String]
args ([String] -> String
unlines [String]
opts)
menuMap :: MonadIO m => String -> M.Map String a -> m (Maybe a)
String
menuCmd = forall (m :: * -> *) a.
MonadIO m =>
String -> [String] -> Map String a -> m (Maybe a)
menuMapArgs String
menuCmd []
menuMapArgs :: MonadIO m => String -> [String] -> M.Map String a ->
m (Maybe a)
String
menuCmd [String]
args Map String a
selectionMap = do
String
selection <- [String] -> m String
menuFunction (forall k a. Map k a -> [k]
M.keys Map String a
selectionMap)
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall k a. Ord k => k -> Map k a -> Maybe a
M.lookup String
selection Map String a
selectionMap
where
menuFunction :: [String] -> m String
menuFunction = forall (m :: * -> *).
MonadIO m =>
String -> [String] -> [String] -> m String
menuArgs String
menuCmd [String]
args
dmenuMap :: MonadIO m => M.Map String a -> m (Maybe a)
= forall (m :: * -> *) a.
MonadIO m =>
String -> Map String a -> m (Maybe a)
menuMap String
"dmenu"