summaryrefslogtreecommitdiffhomepage
path: root/Main.hs
diff options
context:
space:
mode:
authorAndrea Rossato <andrea.rossato@ing.unitn.it>2007-06-26 13:39:48 +0200
committerAndrea Rossato <andrea.rossato@ing.unitn.it>2007-06-26 13:39:48 +0200
commita8ffb9f53aac66b31d4ef870ed88b7c0e6e5ca7e (patch)
tree358cae8830782791a31437eeb4dfad8286e52d83 /Main.hs
parent45ae401703267ec7618ab1315ce5b38af1756c33 (diff)
downloadxmobar-a8ffb9f53aac66b31d4ef870ed88b7c0e6e5ca7e.tar.gz
xmobar-a8ffb9f53aac66b31d4ef870ed88b7c0e6e5ca7e.tar.bz2
splitted files
darcs-hash:20070626113948-d6583-73d318293d1cd91894589450e5cd270dd39bdc02.gz
Diffstat (limited to 'Main.hs')
-rw-r--r--Main.hs51
1 files changed, 51 insertions, 0 deletions
diff --git a/Main.hs b/Main.hs
new file mode 100644
index 0000000..ca2b92f
--- /dev/null
+++ b/Main.hs
@@ -0,0 +1,51 @@
+-----------------------------------------------------------------------------
+-- |
+-- Module : XMobar.Main
+-- Copyright : (c) Andrea Rossato
+-- License : BSD-style (see LICENSE)
+--
+-- Maintainer : Andrea Rossato <andrea.rossato@unibz.it>
+-- Stability : unstable
+-- Portability : unportable
+--
+-- The main module of XMobar, a status bar for the Xmonad Window Manager
+--
+-----------------------------------------------------------------------------
+
+module Main ( -- * Main Stuff
+ -- $main
+ main
+ , readConfig
+ ) where
+
+import XMobar
+import Parsers
+import Config
+import System.Environment
+
+-- $main
+
+-- | The main entry point
+main :: IO ()
+main =
+ do args <- getArgs
+ config <-
+ if length args /= 1
+ then do putStrLn ("No configuration file specified. Using default settings.")
+ return defaultConfig
+ else readConfig (args!!0)
+ cl <- parseTemplate config (template config)
+ var <- execCommands config cl
+ (d,w) <- createWin config
+ runXMobar config var d w eventLoop
+
+-- | Reads the configuration files or quits with an error
+readConfig :: FilePath -> IO Config
+readConfig f =
+ do s <- readFile f
+ case reads s of
+ [(config,_)] -> return config
+ [] -> error ("Corrupt config file: " ++ f)
+ _ -> error ("Some problem occured. Aborting...")
+
+