summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2018-11-26 01:30:39 +0000
committerjao <jao@gnu.org>2018-11-26 01:30:39 +0000
commitf3193c75aced2525f95da8aee3fe6c35eea88b0f (patch)
tree4d71e61e935a725db40ed485a9b2e9352c306a07
parentc2a125cefb0bf41140db398248a5b8523b46a42e (diff)
downloadxmobar-f3193c75aced2525f95da8aee3fe6c35eea88b0f.tar.gz
xmobar-f3193c75aced2525f95da8aee3fe6c35eea88b0f.tar.bz2
New option -D, and keeping silent by default
-rw-r--r--app/Configuration.hs6
-rw-r--r--app/Main.hs19
-rw-r--r--readme.md16
3 files changed, 24 insertions, 17 deletions
diff --git a/app/Configuration.hs b/app/Configuration.hs
index 340124a..3e30730 100644
--- a/app/Configuration.hs
+++ b/app/Configuration.hs
@@ -29,9 +29,11 @@ import qualified Xmobar as X
-- | Reads the configuration files or quits with an error
readConfig :: FilePath -> String -> IO (X.Config,[String])
readConfig f usage = do
- let err m = error $ f ++ ": " ++ m ++ "\n" ++ usage
+ let err m = error $ f ++ ": " ++ m
file <- liftIO $ fileExist f
- r <- if file then X.readConfig X.defaultConfig f else err "file not found"
+ r <- if file
+ then X.readConfig X.defaultConfig f
+ else err $ "file not found" ++ "\n" ++ usage
case r of
Left e -> err (show e)
Right res -> return res
diff --git a/app/Main.hs b/app/Main.hs
index 35bff7d..b5d3993 100644
--- a/app/Main.hs
+++ b/app/Main.hs
@@ -38,11 +38,12 @@ main = do
(c,defaultings) <- case file of
[cfgfile] -> C.readConfig cfgfile usage
_ -> C.readDefaultConfig usage
- unless (null defaultings) $ putStrLn $
+ unless (null defaultings || (not $ any (== Debug) o)) $ putStrLn $
"Fields missing from config defaulted: " ++ intercalate "," defaultings
doOpts c o >>= xmobar
data Opts = Help
+ | Debug
| Version
| Font String
| BgColor String
@@ -61,13 +62,14 @@ data Opts = Help
| Position String
| WmClass String
| WmName String
- deriving Show
+ deriving (Show, Eq)
options :: [OptDescr Opts]
options =
[ Option "h?" ["help"] (NoArg Help) "This help"
+ , Option "D" ["debug"] (NoArg Debug) "Emit verbose debugging messages"
, Option "V" ["version"] (NoArg Version) "Show version information"
- , Option "f" ["font"] (ReqArg Font "font name") "The font name"
+ , Option "f" ["font"] (ReqArg Font "font name") "Font name"
, Option "w" ["wmclass"] (ReqArg WmClass "class") "X11 WM_CLASS property"
, Option "n" ["wmname"] (ReqArg WmName "name") "X11 WM_NAME property"
, Option "B" ["bgcolor"] (ReqArg BgColor "bg color" )
@@ -77,7 +79,7 @@ options =
, Option "i" ["iconroot"] (ReqArg IconRoot "path")
"Root directory for icon pattern paths. Default '.'"
, Option "A" ["alpha"] (ReqArg Alpha "alpha")
- "The transparency: 0 is transparent, 255 is opaque. Default: 255"
+ "Transparency: 0 is transparent, 255 is opaque. Default: 255"
, Option "o" ["top"] (NoArg T) "Place xmobar at the top of the screen"
, Option "b" ["bottom"] (NoArg B)
"Place xmobar at the bottom of the screen"
@@ -86,12 +88,12 @@ options =
, Option "a" ["alignsep"] (ReqArg AlignSep "alignsep")
"Separators for left, center and right text\nalignment. Default: '}{'"
, Option "s" ["sepchar"] (ReqArg SepChar "char")
- ("The character used to separate commands in" ++
+ ("Character used to separate commands in" ++
"\nthe output template. Default '%'")
, Option "t" ["template"] (ReqArg Template "template")
- "The output template"
+ "Output template"
, Option "c" ["commands"] (ReqArg Commands "commands")
- "The list of commands to be executed"
+ "List of commands to be executed"
, Option "C" ["add-command"] (ReqArg AddCommand "command")
"Add to the list of commands to be executed"
, Option "x" ["screen"] (ReqArg OnScr "screen")
@@ -133,6 +135,7 @@ doOpts conf (o:oo) =
case o of
Help -> putStr usage >> exitSuccess
Version -> putStrLn info >> exitSuccess
+ Debug -> doOpts' conf
Font s -> doOpts' (conf {font = s})
WmClass s -> doOpts' (conf {wmClass = s})
WmName s -> doOpts' (conf {wmName = s})
@@ -160,7 +163,7 @@ doOpts conf (o:oo) =
_ -> Left ("xmobar: cannot read list of commands " ++
"specified with the -" ++ c:" option\n")
readStr str = [x | (x,t) <- reads str, ("","") <- lex t]
- doOpts' opts = doOpts opts oo
+ doOpts' c = doOpts c oo
readPosition string =
case readMaybe string of
Just x -> doOpts' (conf { position = x })
diff --git a/readme.md b/readme.md
index 9332c52..77c99e1 100644
--- a/readme.md
+++ b/readme.md
@@ -370,23 +370,25 @@ xmobar --help):
Options:
-h, -? --help This help
-V --version Show version information
- -f font name --font=font name The font name
+ -D --debug Emit verbose debugging messages
+ -f font name --font=font name Font name
-w class --wmclass=class X11 WM_CLASS property
-n name --wmname=name X11 WM_NAME property
- -B bg color --bgcolor=bg color The background color. Default black
- -F fg color --fgcolor=fg color The foreground color. Default grey
- -A alpha --alpha=alpha The transparency: 0 is transparent, 255 (the default) is opaque
+ -B bg color --bgcolor=bg color Background color. Default black
+ -F fg color --fgcolor=fg color Foreground color. Default grey
+ -A alpha --alpha=alpha Transparency: 0 is transparent
+ and 255 (the default) is opaque
-o --top Place xmobar at the top of the screen
-b --bottom Place xmobar at the bottom of the screen
-p --position=position Specify position, same as in config file
-d --dock Try to start xmobar as a dock
-a alignsep --alignsep=alignsep Separators for left, center and right text
alignment. Default: '}{'
- -s char --sepchar=char The character used to separate commands in
+ -s char --sepchar=char Character used to separate commands in
the output template. Default '%'
- -t template --template=template The output template
+ -t template --template=template Output template
-i path --iconroot=path Default directory for icon pattern files
- -c commands --commands=commands The list of commands to be executed
+ -c commands --commands=commands List of commands to be executed
-C command --add-command=command Add to the list of commands to be executed
-x screen --screen=screen On which X screen number to start