summaryrefslogtreecommitdiff
path: root/Utility
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-08-02 07:47:20 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-08-02 07:47:20 -0400
commitadf5789c1b6c80549d28284834b91a1cbddc90c9 (patch)
tree154e529f75b8240381c6099d70b845f6e483d8c4 /Utility
parent60da0d6ad28bff7c601ba631a8ec65030f940367 (diff)
fix bugs, add desktop dir
Diffstat (limited to 'Utility')
-rw-r--r--Utility/FreeDesktop.hs29
1 files changed, 20 insertions, 9 deletions
diff --git a/Utility/FreeDesktop.hs b/Utility/FreeDesktop.hs
index 784473b27..f2168077a 100644
--- a/Utility/FreeDesktop.hs
+++ b/Utility/FreeDesktop.hs
@@ -19,7 +19,8 @@ module Utility.FreeDesktop (
systemDataDir,
systemConfigDir,
userDataDir,
- userConfigDir
+ userConfigDir,
+ userDesktopDir
) where
import Utility.Exception
@@ -72,10 +73,14 @@ writeDesktopMenuFile d file = do
createDirectoryIfMissing True (parentDir file)
writeFile file $ buildDesktopMenuFile d
+{- Path to use for a desktop menu file, in either the systemDataDir or
+ - the userDataDir -}
desktopMenuFilePath :: String -> FilePath -> FilePath
desktopMenuFilePath basename datadir =
datadir </> "applications" </> desktopfile basename
+{- Path to use for a desktop autostart file, in either the systemDataDir
+ - or the userDataDir -}
autoStartPath :: String -> FilePath -> FilePath
autoStartPath basename configdir =
configdir </> "autostart" </> desktopfile basename
@@ -83,21 +88,27 @@ autoStartPath basename configdir =
desktopfile :: FilePath -> FilePath
desktopfile f = f ++ ".desktop"
+{- Directory used for installation of system wide data files.. -}
systemDataDir :: FilePath
systemDataDir = "/usr/share"
+{- Directory used for installation of system wide config files. -}
systemConfigDir :: FilePath
systemConfigDir = "/etc/xdg"
+{- Directory for user data files. -}
userDataDir :: IO FilePath
-userDataDir = do
- dir <- xdgEnv "DATA_HOME" =<< myHomeDir
- return $ dir </> ".local" </> "share"
+userDataDir = xdgEnvHome "DATA_HOME" ".local/share"
+{- Directory for user config files. -}
userConfigDir :: IO FilePath
-userConfigDir = do
- dir <- xdgEnv "CONFIG_HOME" =<< myHomeDir
- return $ dir </> ".config"
+userConfigDir = xdgEnvHome "CONFIG_HOME" ".config"
-xdgEnv :: String -> String -> IO String
-xdgEnv envbase def = catchDefaultIO (getEnv $ "XDG_" ++ envbase) def
+{- Directory for the user's Desktop, may be localized. -}
+userDesktopDir :: IO FilePath
+userDesktopDir = xdgEnvHome "DESKTOP_DIR" "Desktop"
+
+xdgEnvHome :: String -> String -> IO String
+xdgEnvHome envbase homedef = do
+ home <- myHomeDir
+ catchDefaultIO (getEnv $ "XDG_" ++ envbase) (home </> homedef)