diff options
Diffstat (limited to 'src/Main.hs')
-rw-r--r-- | src/Main.hs | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/src/Main.hs b/src/Main.hs index f7a70ff..4146c1c 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -37,7 +37,7 @@ import System.Exit import System.Environment import System.FilePath ((</>)) import System.Posix.Files -import Control.Monad (unless) +import Control.Monad (unless, liftM) import Signal (setupSignalHandler) @@ -94,25 +94,27 @@ xdgConfigDir :: IO String xdgConfigDir = do env <- getEnvironment case lookup "XDG_CONFIG_HOME" env of Just val -> return val - Nothing -> getHomeDirectory >>= return . (</> ".config") + Nothing -> liftM (</> ".config") getHomeDirectory xmobarConfigDir :: IO FilePath -xmobarConfigDir = xdgConfigDir >>= return . (</> "xmobar") +xmobarConfigDir = liftM (</> "xmobar") xdgConfigDir getXdgConfigFile :: IO FilePath -getXdgConfigFile = xmobarConfigDir >>= return . (</> "xmobarrc") +getXdgConfigFile = liftM (</> "xmobarrc") xmobarConfigDir -- | Read default configuration file or load the default config readDefaultConfig :: IO (Config,[String]) readDefaultConfig = do - xdgconf <- getXdgConfigFile - x <- io $ fileExist xdgconf + xdgConfigFile <- getXdgConfigFile + xdgConfigFileExists <- io $ fileExist xdgConfigFile home <- io $ getEnv "HOME" - let path = home ++ "/.xmobarrc" - f <- io $ fileExist path - if x then readConfig path - else if f then readConfig path - else return (defaultConfig,[]) + let defaultConfigFile = home ++ "/.xmobarrc" + defaultConfigFileExists <- io $ fileExist defaultConfigFile + if xdgConfigFileExists + then readConfig xdgConfigFile + else if defaultConfigFileExists + then readConfig defaultConfigFile + else return (defaultConfig,[]) data Opts = Help | Version @@ -129,6 +131,7 @@ data Opts = Help | SepChar String | Template String | OnScr String + | IconRoot String deriving Show options :: [OptDescr Opts] @@ -140,6 +143,8 @@ options = "The background color. Default black" , Option "F" ["fgcolor"] (ReqArg FgColor "fg color") "The foreground color. Default grey" + , 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" , Option "o" ["top"] (NoArg T) "Place xmobar at the top of the screen" @@ -176,7 +181,7 @@ usage = usageInfo header options ++ footer info :: String info = "xmobar " ++ showVersion version ++ "\n (C) 2007 - 2010 Andrea Rossato " - ++ "\n (C) 2010 - 2013 Jose A Ortega Ruiz\n " + ++ "\n (C) 2010 - 2014 Jose A Ortega Ruiz\n " ++ mail ++ "\n" ++ license mail :: String @@ -189,7 +194,7 @@ license = "\nThis program is distributed in the hope that it will be useful," ++ "\nSee the License for more details." doOpts :: Config -> [Opts] -> IO Config -doOpts conf [] = +doOpts conf [] = return (conf {lowerOnStart = lowerOnStart conf && overrideRedirect conf}) doOpts conf (o:oo) = case o of @@ -205,6 +210,7 @@ doOpts conf (o:oo) = AlignSep s -> doOpts' (conf {alignSep = s}) SepChar s -> doOpts' (conf {sepChar = s}) Template s -> doOpts' (conf {template = s}) + IconRoot s -> doOpts' (conf {iconRoot = s}) OnScr n -> doOpts' (conf {position = OnScreen (read n) $ position conf}) Commands s -> case readCom 'c' s of Right x -> doOpts' (conf {commands = x}) |