summaryrefslogtreecommitdiffhomepage
path: root/Main.hs
diff options
context:
space:
mode:
authorAndrea Rossato <andrea.rossato@ing.unitn.it>2007-07-24 11:44:35 +0200
committerAndrea Rossato <andrea.rossato@ing.unitn.it>2007-07-24 11:44:35 +0200
commit9928c4c9ea1648c0735b1219e15f00307cacfa0d (patch)
treeba75b30bce11b756bbe68890e0dc7e13f231e39b /Main.hs
parent1209c4f6bb3218cacdfbd7337488abf4bcb05245 (diff)
downloadxmobar-9928c4c9ea1648c0735b1219e15f00307cacfa0d.tar.gz
xmobar-9928c4c9ea1648c0735b1219e15f00307cacfa0d.tar.bz2
code and output cleanup
darcs-hash:20070724094435-d6583-dec41cb61e2f547ae45835873aadcbb0fc21dd8e.gz
Diffstat (limited to 'Main.hs')
-rw-r--r--Main.hs63
1 files changed, 38 insertions, 25 deletions
diff --git a/Main.hs b/Main.hs
index dd8baaf..45b550f 100644
--- a/Main.hs
+++ b/Main.hs
@@ -106,11 +106,21 @@ getOpts argv =
(_,_,errs) -> error (concat errs ++ usage)
usage :: String
-usage = usageInfo header options
- where header = "Usage: xmobar [OPTION...] [FILE]"
+usage = (usageInfo header options) ++ footer
+ where header = "Usage: xmobar [OPTION...] [FILE]\nOptions:"
+ footer = "Mail bug reports and suggestions to " ++ mail
version :: String
-version = "Xmobar 0.7 (c) 2007 Andrea Rossato <andrea.rossato@unibz.it>"
+version = "Xmobar 0.7 (c) 2007 Andrea Rossato " ++ mail ++ license
+
+mail :: String
+mail = "<andrea.rossato@unibz.it>\n"
+
+license :: String
+license = "\nThis program is distributed in the hope that it will be useful,\n" ++
+ "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" ++
+ "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n" ++
+ "See the License for more details."
doOpts :: IORef Config -> [Opts] -> IO ()
doOpts _ [] = return ()
@@ -118,25 +128,28 @@ doOpts conf (o:oo) =
case o of
Help -> putStr usage >> exitWith ExitSuccess
Version -> putStrLn version >> exitWith ExitSuccess
- Font s -> modifyIORef conf (\c -> c { font = s }) >> doOpts conf oo
- BgColor s -> modifyIORef conf (\c -> c { bgColor = s }) >> doOpts conf oo
- FgColor s -> modifyIORef conf (\c -> c { fgColor = s }) >> doOpts conf oo
- XPos s -> modifyIORef conf (\c -> c { xPos = readInt s c xPos}) >> doOpts conf oo
- YPos s -> modifyIORef conf (\c -> c { yPos = readInt s c yPos }) >> doOpts conf oo
- Width s -> modifyIORef conf (\c -> c { width = readInt s c width }) >> doOpts conf oo
- Height s -> modifyIORef conf (\c -> c { height = readInt s c height }) >> doOpts conf oo
- Align s -> modifyIORef conf (\c -> c { align = s }) >> doOpts conf oo
- Refresh s -> modifyIORef conf (\c -> c { refresh = readInt s c refresh }) >> doOpts conf oo
- SepChar s -> modifyIORef conf (\c -> c { sepChar = s }) >> doOpts conf oo
- Template s -> modifyIORef conf (\c -> c { template = s }) >> doOpts conf oo
- Commands s -> do case readCom s of
- Right x -> modifyIORef conf ((\v c -> c { commands = v }) x) >> doOpts conf oo
- Left e -> putStr (e ++ usage) >> exitWith (ExitFailure 1)
- where readCom :: Read a => String -> Either String a
- readCom str = case readStr str of
- [x] -> Right x
- _ -> Left "xmobar: cannot read list of commands specified with the -c option\n"
- readInt str c f = case readStr str of
- [x] -> x
- _ -> f c
- readStr str = [x | (x,t) <- reads str, ("","") <- lex t]
+ Font s -> modifyIORef conf (\c -> c { font = s }) >> go
+ BgColor s -> modifyIORef conf (\c -> c { bgColor = s }) >> go
+ FgColor s -> modifyIORef conf (\c -> c { fgColor = s }) >> go
+ XPos s -> modifyIORef conf (\c -> c { xPos = readInt s c xPos}) >> go
+ YPos s -> modifyIORef conf (\c -> c { yPos = readInt s c yPos }) >> go
+ Width s -> modifyIORef conf (\c -> c { width = readInt s c width }) >> go
+ Height s -> modifyIORef conf (\c -> c { height = readInt s c height }) >> go
+ Align s -> modifyIORef conf (\c -> c { align = s }) >> go
+ Refresh s -> modifyIORef conf (\c -> c { refresh = readInt s c refresh }) >> go
+ SepChar s -> modifyIORef conf (\c -> c { sepChar = s }) >> go
+ Template s -> modifyIORef conf (\c -> c { template = s }) >> go
+ Commands s -> case readCom s of
+ Right x -> modifyIORef conf (\c -> c { commands = x })>> go
+ Left e -> putStr (e ++ usage) >> exitWith (ExitFailure 1)
+ where readCom str =
+ case readStr str of
+ [x] -> Right x
+ _ -> Left "xmobar: cannot read list of commands specified with the -c option\n"
+ readInt str c f =
+ case readStr str of
+ [x] -> x
+ _ -> f c
+ readStr str =
+ [x | (x,t) <- reads str, ("","") <- lex t]
+ go = doOpts conf oo \ No newline at end of file