summaryrefslogtreecommitdiffhomepage
path: root/src/Main.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Main.hs')
-rw-r--r--src/Main.hs17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/Main.hs b/src/Main.hs
index aad2804..e90a158 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -32,9 +32,10 @@ import Paths_xmobar (version)
import Data.Version (showVersion)
import Graphics.X11.Xlib
import System.Console.GetOpt
+import System.Directory (getHomeDirectory)
import System.Exit
import System.Environment
-import System.Environment.XDG.BaseDir
+import System.FilePath ((</>))
import System.Posix.Files
import Control.Monad (unless)
@@ -89,10 +90,22 @@ readConfig f = do
": configuration file contains errors at:\n" ++ show err)
return $ parseConfig s
+xdgConfigDir :: IO String
+xdgConfigDir = do env <- getEnvironment
+ case lookup "XDG_CONFIG_HOME" env of
+ Just val -> return val
+ Nothing -> getHomeDirectory >>= return . (</> ".config")
+
+xmobarConfigDir :: IO FilePath
+xmobarConfigDir = xdgConfigDir >>= return . (</> "xmobar")
+
+getXdgConfigFile :: IO FilePath
+getXdgConfigFile = xmobarConfigDir >>= return . (</> "xmobarrc")
+
-- | Read default configuration file or load the default config
readDefaultConfig :: IO (Config,[String])
readDefaultConfig = do
- xdgconf <- getUserDataFile "xmobar" "xmobarrc"
+ xdgconf <- getXdgConfigFile
x <- io $ fileExist xdgconf
home <- io $ getEnv "HOME"
let path = home ++ "/.xmobarrc"