summaryrefslogtreecommitdiffhomepage
path: root/src/Xmobar
diff options
context:
space:
mode:
Diffstat (limited to 'src/Xmobar')
-rw-r--r--src/Xmobar/App/Main.hs17
-rw-r--r--src/Xmobar/App/Opts.hs7
2 files changed, 14 insertions, 10 deletions
diff --git a/src/Xmobar/App/Main.hs b/src/Xmobar/App/Main.hs
index b5de2ef..2291852 100644
--- a/src/Xmobar/App/Main.hs
+++ b/src/Xmobar/App/Main.hs
@@ -73,8 +73,8 @@ buildLaunch verb force p = do
recompile dir exec force verb
executeFile (dir </> exec) False [] Nothing
-xmobar' :: Config -> [String] -> IO ()
-xmobar' cfg defs = do
+xmobar' :: [String] -> Config -> IO ()
+xmobar' defs cfg = do
unless (null defs || not (verbose cfg)) $ putStrLn $
"Fields missing from config defaulted: " ++ intercalate "," defs
xmobar cfg
@@ -84,14 +84,15 @@ xmobarMain = do
args <- getArgs
(flags, rest) <- getOpts args
cf <- case rest of
- (c:_) -> return (Just c)
- _ -> xmobarConfigFile
+ [c] -> return (Just c)
+ [] -> xmobarConfigFile
+ _ -> error $ "Too many arguments: " ++ show rest
case cf of
Nothing -> case rest of
(c:_) -> error $ c ++ ": file not found"
_ -> xmobar defaultConfig
- Just p -> do d <- doOpts defaultConfig flags
- r <- readConfig d p
+ Just p -> do r <- readConfig defaultConfig p
case r of
- Left _ -> buildLaunch (verbose d) (forceRecompile flags) p
- Right (c, defs) -> xmobar' c defs
+ Left _ ->
+ buildLaunch (verboseFlag flags) (recompileFlag flags) p
+ Right (c, defs) -> doOpts c flags >>= xmobar' defs
diff --git a/src/Xmobar/App/Opts.hs b/src/Xmobar/App/Opts.hs
index 34e2c9e..07428d2 100644
--- a/src/Xmobar/App/Opts.hs
+++ b/src/Xmobar/App/Opts.hs
@@ -161,5 +161,8 @@ doOpts conf (o:oo) =
putStrLn "Can't parse position option, ignoring"
doOpts' conf
-forceRecompile :: [Opts] -> Bool
-forceRecompile = elem Recompile
+recompileFlag :: [Opts] -> Bool
+recompileFlag = elem Recompile
+
+verboseFlag :: [Opts] -> Bool
+verboseFlag = elem Verbose