From 9fc6b376a58e83eecb33a55f88175a71e613aa25 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 5 Jul 2013 00:09:46 -0400 Subject: Implement XDG logic locally Avoids an extra dependency. --- src/Main.hs | 17 +++++++++++++++-- xmobar.cabal | 3 +-- 2 files changed, 16 insertions(+), 4 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" diff --git a/xmobar.cabal b/xmobar.cabal index de80bbf..2ba7e57 100644 --- a/xmobar.cabal +++ b/xmobar.cabal @@ -108,8 +108,7 @@ executable xmobar X11 >= 1.6.1, mtl >= 2.0 && < 2.2, parsec == 3.1.*, - stm >= 2.3 && < 2.5, - xdg-basedir == 0.2.* + stm >= 2.3 && < 2.5 if flag(with_threaded) -- -threaded is a workaround for 100% CPU busy loop -- cgit v1.2.3