summaryrefslogtreecommitdiffhomepage
path: root/src/Xmobar
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2018-12-04 21:25:28 +0000
committerjao <jao@gnu.org>2018-12-04 21:25:28 +0000
commitbad2dbf52d16f00d630636f2137eac16f736b138 (patch)
tree011dbeb302b3a41f892aca80edede5c747d0cb68 /src/Xmobar
parentd48e752fb87555efb05f1251e6510b7cfdfa71d1 (diff)
downloadxmobar-bad2dbf52d16f00d630636f2137eac16f736b138.tar.gz
xmobar-bad2dbf52d16f00d630636f2137eac16f736b138.tar.bz2
Fix: honour command line flags
Fixes #370, and then some
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