haskell - How to use IO String function in Xmonad key bindings? -
i've configured xmonad launch dmenu_path:
((mymodmask, xk_p), spawn (shome ++ "/.xmonad/dmenu_path")) spawn runs script, dmenu_path runs dmenu , exec command.
~/.xmonad/dmenu_path:
eval "exec $(dmenu)" i'd replace script haskell function. i've write simple 'io string' function (fdmenupath :: io string) in ~/.xmonad/xmonad.hs. i'd like:
((mymodmask, xk_p), spawn (fdmenupath)) running xmonad --recompile shows error:
xmonad.hs:130:35 couldn't match type `io string' `[char]' expected type: string actual type: io string .... i'm newbie haskell. don't know how use function retrieve result string, , pass spawn.
any suggestion, please?
this code fdmenupath:
pdmpcmd1 p = proc "echo" [p] pdmpcmd2 = proc "tr" [":","\\n"] pdmpcmd3 = proc "uniq" [] pdmpcmd4 = proc "sed" ["s|$|/|"] pdmpcmd5 = proc "xargs" ["ls","-lu","--time-style=+%s"] pdmpcmd6 = proc "awk" ["/^(-|l)/ { print $6, $7 }"] pdmpcmd7 = proc "sort" ["-rn"] pdmpcmd8 = proc "cut" ["-d ","-f","2"] pdmpcmd9 = proc "dmenu" ["-fn","-*-terminus-*-r-normal-*-*-120-*-*-*-*-iso8859-*","-nb","#000000","-nf","#839496","-sb","#859900"] fdmenupath :: io string fdmenupath = spath <- getenv "path" (_, ho1, _, hp1) <- createprocess (pdmpcmd1 spath) { std_out = createpipe } (_, ho2, _, hp2) <- createprocess pdmpcmd2 { std_in = usehandle ho1 , std_out = createpipe } (_, ho3, _, hp3) <- createprocess pdmpcmd3 { std_in = usehandle ho2 , std_out = createpipe } (_, ho4, _, hp4) <- createprocess pdmpcmd4 { std_in = usehandle ho3 , std_out = createpipe } (_, ho5, _, hp5) <- createprocess pdmpcmd5 { std_in = usehandle ho4 , std_out = createpipe } (_, ho6, _, hp6) <- createprocess pdmpcmd6 { std_in = usehandle ho5 , std_out = createpipe } (_, ho7, _, hp7) <- createprocess pdmpcmd7 { std_in = usehandle ho6 , std_out = createpipe } (_, ho8, _, hp8) <- createprocess pdmpcmd8 { std_in = usehandle ho7 , std_out = createpipe } (_, ho9, _, hp9) <- createprocess pdmpcmd9 { std_in = usehandle ho8 , std_out = createpipe } sout <- hgetcontents ho9 ec1 <- waitforprocess hp1 ec2 <- waitforprocess hp2 ec3 <- waitforprocess hp3 ec4 <- waitforprocess hp4 ec5 <- waitforprocess hp5 ec6 <- waitforprocess hp6 ec7 <- waitforprocess hp7 ec8 <- waitforprocess hp8 ec9 <- waitforprocess hp9 return $ sout thanks
the 2 pieces you're looking are
liftio :: io -> x (>>=) :: x -> (a -> x b) -> x b combining them,
liftio fdmenupath >>= spawn :: x ()
Comments
Post a Comment