fix bugs, add desktop dir
This commit is contained in:
parent
60da0d6ad2
commit
adf5789c1b
1 changed files with 20 additions and 9 deletions
|
@ -19,7 +19,8 @@ module Utility.FreeDesktop (
|
||||||
systemDataDir,
|
systemDataDir,
|
||||||
systemConfigDir,
|
systemConfigDir,
|
||||||
userDataDir,
|
userDataDir,
|
||||||
userConfigDir
|
userConfigDir,
|
||||||
|
userDesktopDir
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Utility.Exception
|
import Utility.Exception
|
||||||
|
@ -72,10 +73,14 @@ writeDesktopMenuFile d file = do
|
||||||
createDirectoryIfMissing True (parentDir file)
|
createDirectoryIfMissing True (parentDir file)
|
||||||
writeFile file $ buildDesktopMenuFile d
|
writeFile file $ buildDesktopMenuFile d
|
||||||
|
|
||||||
|
{- Path to use for a desktop menu file, in either the systemDataDir or
|
||||||
|
- the userDataDir -}
|
||||||
desktopMenuFilePath :: String -> FilePath -> FilePath
|
desktopMenuFilePath :: String -> FilePath -> FilePath
|
||||||
desktopMenuFilePath basename datadir =
|
desktopMenuFilePath basename datadir =
|
||||||
datadir </> "applications" </> desktopfile basename
|
datadir </> "applications" </> desktopfile basename
|
||||||
|
|
||||||
|
{- Path to use for a desktop autostart file, in either the systemDataDir
|
||||||
|
- or the userDataDir -}
|
||||||
autoStartPath :: String -> FilePath -> FilePath
|
autoStartPath :: String -> FilePath -> FilePath
|
||||||
autoStartPath basename configdir =
|
autoStartPath basename configdir =
|
||||||
configdir </> "autostart" </> desktopfile basename
|
configdir </> "autostart" </> desktopfile basename
|
||||||
|
@ -83,21 +88,27 @@ autoStartPath basename configdir =
|
||||||
desktopfile :: FilePath -> FilePath
|
desktopfile :: FilePath -> FilePath
|
||||||
desktopfile f = f ++ ".desktop"
|
desktopfile f = f ++ ".desktop"
|
||||||
|
|
||||||
|
{- Directory used for installation of system wide data files.. -}
|
||||||
systemDataDir :: FilePath
|
systemDataDir :: FilePath
|
||||||
systemDataDir = "/usr/share"
|
systemDataDir = "/usr/share"
|
||||||
|
|
||||||
|
{- Directory used for installation of system wide config files. -}
|
||||||
systemConfigDir :: FilePath
|
systemConfigDir :: FilePath
|
||||||
systemConfigDir = "/etc/xdg"
|
systemConfigDir = "/etc/xdg"
|
||||||
|
|
||||||
|
{- Directory for user data files. -}
|
||||||
userDataDir :: IO FilePath
|
userDataDir :: IO FilePath
|
||||||
userDataDir = do
|
userDataDir = xdgEnvHome "DATA_HOME" ".local/share"
|
||||||
dir <- xdgEnv "DATA_HOME" =<< myHomeDir
|
|
||||||
return $ dir </> ".local" </> "share"
|
|
||||||
|
|
||||||
|
{- Directory for user config files. -}
|
||||||
userConfigDir :: IO FilePath
|
userConfigDir :: IO FilePath
|
||||||
userConfigDir = do
|
userConfigDir = xdgEnvHome "CONFIG_HOME" ".config"
|
||||||
dir <- xdgEnv "CONFIG_HOME" =<< myHomeDir
|
|
||||||
return $ dir </> ".config"
|
|
||||||
|
|
||||||
xdgEnv :: String -> String -> IO String
|
{- Directory for the user's Desktop, may be localized. -}
|
||||||
xdgEnv envbase def = catchDefaultIO (getEnv $ "XDG_" ++ envbase) def
|
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)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue