summaryrefslogtreecommitdiffhomepage
path: root/src/Xmobar
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2022-10-01 02:58:23 +0100
committerjao <jao@gnu.org>2022-10-01 02:58:23 +0100
commitac3b8212a68052f99eba2bd74a2dd8aa9ca2dcb2 (patch)
tree85900083aec42915c3ebab1af352f48ca4f690c6 /src/Xmobar
parentef380c045957413948d390c152f6401869526285 (diff)
downloadxmobar-ac3b8212a68052f99eba2bd74a2dd8aa9ca2dcb2.tar.gz
xmobar-ac3b8212a68052f99eba2bd74a2dd8aa9ca2dcb2.tar.bz2
a couple of superfluous IO usages removed
Diffstat (limited to 'src/Xmobar')
-rw-r--r--src/Xmobar/Config/Template.hs14
-rw-r--r--src/Xmobar/Text/Loop.hs2
-rw-r--r--src/Xmobar/Text/Output.hs8
-rw-r--r--src/Xmobar/X11/Loop.hs2
4 files changed, 12 insertions, 14 deletions
diff --git a/src/Xmobar/Config/Template.hs b/src/Xmobar/Config/Template.hs
index 28ccbe1..67ed061 100644
--- a/src/Xmobar/Config/Template.hs
+++ b/src/Xmobar/Config/Template.hs
@@ -21,23 +21,21 @@ import Control.Monad (guard, mzero)
import Data.Maybe (fromMaybe)
import Text.Parsec ((<|>))
+import Text.Read (readMaybe)
+
import qualified Text.Parsec as P
import qualified Text.Parsec.Combinator as C
-import Text.ParserCombinators.Parsec (Parser)
-import Text.Read (readMaybe)
+import Text.ParserCombinators.Parsec (Parser)
import Xmobar.Config.Types
-- | Runs the template string parser
-parseString :: Config -> String -> IO [Segment]
+parseString :: Config -> String -> [Segment]
parseString c s =
case P.parse (stringParser ci 0 Nothing) "" s of
- Left _ -> return [(Text $ "Could not parse string: " ++ s
- , ci
- , 0
- , Nothing)]
- Right x -> return (concat x)
+ Left _ -> [(Text $ "Could not parse string: " ++ s , ci , 0 , Nothing)]
+ Right x -> concat x
where ci = TextRenderInfo (fgColor c) 0 0 []
allParsers :: TextRenderInfo -> FontIndex -> Maybe [Action] -> Parser [Segment]
diff --git a/src/Xmobar/Text/Loop.hs b/src/Xmobar/Text/Loop.hs
index 05379cd..5d2c43f 100644
--- a/src/Xmobar/Text/Loop.hs
+++ b/src/Xmobar/Text/Loop.hs
@@ -45,4 +45,4 @@ eventLoop cfg signal tv = do
updateString :: Config -> TVar [String] -> IO String
updateString conf v = do
s <- readTVarIO v
- format conf (concat s)
+ return $ format conf (concat s)
diff --git a/src/Xmobar/Text/Output.hs b/src/Xmobar/Text/Output.hs
index 6e5b0f1..677b6d2 100644
--- a/src/Xmobar/Text/Output.hs
+++ b/src/Xmobar/Text/Output.hs
@@ -49,9 +49,9 @@ formatWithColor conf (Hspace n, i, x, y) =
formatWithColor conf (Text $ replicate (fromIntegral n) ' ', i, x, y)
formatWithColor _ _ = ""
-format :: Config -> String -> IO String
+format :: Config -> String -> String
format conf s = do
- segments <- parseString conf s
+ let segments = parseString conf s
case textOutputFormat conf of
- Swaybar -> return $ formatSwaybar conf segments
- _ -> return (concatMap (formatWithColor conf) segments)
+ Swaybar -> formatSwaybar conf segments
+ _ -> concatMap (formatWithColor conf) segments
diff --git a/src/Xmobar/X11/Loop.hs b/src/Xmobar/X11/Loop.hs
index 721a35b..da16402 100644
--- a/src/Xmobar/X11/Loop.hs
+++ b/src/Xmobar/X11/Loop.hs
@@ -149,7 +149,7 @@ parseSegments :: C.Config -> STM.TVar [String] -> IO [[C.Segment]]
parseSegments conf v = do
s <- STM.readTVarIO v
let l:c:r:_ = s ++ repeat ""
- MR.liftIO $ mapM (CT.parseString conf) [l, c, r]
+ return $ map (CT.parseString conf) [l, c, r]
updateIconCache :: T.XConf -> [[C.Segment]] -> IO T.XConf
updateIconCache xc@(T.XConf d _ w _ c cfg) segs = do