diff options
author | Ben Boeckel <mathstuf@gmail.com> | 2013-07-05 00:09:46 -0400 |
---|---|---|
committer | Ben Boeckel <mathstuf@gmail.com> | 2013-07-05 00:09:46 -0400 |
commit | 9fc6b376a58e83eecb33a55f88175a71e613aa25 (patch) | |
tree | 6a5c06e09cc2712f2c22d90016560e1a4565a97c | |
parent | 7b0d6bffd5c13234feb798604e01fa6a6f91ec6b (diff) | |
download | xmobar-9fc6b376a58e83eecb33a55f88175a71e613aa25.tar.gz xmobar-9fc6b376a58e83eecb33a55f88175a71e613aa25.tar.bz2 |
Implement XDG logic locally
Avoids an extra dependency.
-rw-r--r-- | src/Main.hs | 17 | ||||
-rw-r--r-- | 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 |