Permalink
Browse files

Fix: honour command line flags

Fixes #370, and then some
  • Loading branch information...
jaor committed Dec 4, 2018
1 parent d48e752 commit bad2dbf52d16f00d630636f2137eac16f736b138
Showing with 23 additions and 10 deletions.
  1. +9 −0 changelog.md
  2. +9 −8 src/Xmobar/App/Main.hs
  3. +5 −2 src/Xmobar/App/Opts.hs
@@ -1,3 +1,12 @@
## Version 0.29.1 (December, 2018)

_Bug fixes_

- Honour command line flags (fixes [issue #370])
- Expose Cmd and CmdX in Xmobar interface

[issue #370]: https://github.com/jaor/xmobar/issues/370

## Version 0.29 (December, 2018)

_New features_
@@ -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
@@ -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

0 comments on commit bad2dbf

Please sign in to comment.