diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/Main.hs | 41 |
1 files changed, 1 insertions, 40 deletions
diff --git a/app/Main.hs b/app/Main.hs index 3c17447..ac618ce 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE FlexibleContexts #-} ----------------------------------------------------------------------------- -- | -- Module : Xmobar.Main @@ -15,45 +14,7 @@ module Main (main) where -import Data.List (intercalate) - -import System.Environment (getArgs) -import Control.Monad (unless) -import System.Posix.Files (fileExist) - import Xmobar -import Xmobar.App.Main -import Xmobar.App.Opts - --- $main --- | The main entry point main :: IO () -main = do - (o,file) <- getArgs >>= getOpts - (c,defaultings) <- case file of - [cfgfile] -> config cfgfile usage - _ -> defConfig usage - unless (null defaultings || notElem Debug o) $ putStrLn $ - "Fields missing from config defaulted: " ++ intercalate "," defaultings - doOpts c o >>= xmobar - --- | Read default configuration file or load the default config -defConfig :: String -> IO (Config,[String]) -defConfig msg = do - xdgConfigFile <- xmobarConfigFile - xdgConfigFileExists <- fileExist xdgConfigFile - if xdgConfigFileExists - then config xdgConfigFile msg - else return (defaultConfig,[]) - -config :: FilePath -> String -> IO (Config,[String]) -config f msg = do - let err m = error $ f ++ ": " ++ m - file <- fileExist f - r <- if file - then readConfig defaultConfig f - else err $ "file not found" ++ "\n" ++ msg - case r of - Left e -> err (show e) - Right res -> return res +main = xmobarMain |