aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Utility/FreeDesktop.hs18
1 files changed, 9 insertions, 9 deletions
diff --git a/Utility/FreeDesktop.hs b/Utility/FreeDesktop.hs
index abaa313df..896b89b99 100644
--- a/Utility/FreeDesktop.hs
+++ b/Utility/FreeDesktop.hs
@@ -29,16 +29,13 @@ module Utility.FreeDesktop (
) where
import Utility.Exception
-import Utility.Path
import Utility.UserInfo
import Utility.Process
-import Utility.PartialPrelude
-import Utility.Directory
import System.Environment
import System.FilePath
+import System.Directory
import Data.List
-import Data.String.Utils
import Data.Maybe
import Control.Applicative
import Prelude
@@ -54,12 +51,13 @@ toString (StringV s) = s
toString (BoolV b)
| b = "true"
| otherwise = "false"
-toString(NumericV f) = show f
+toString (NumericV f) = show f
toString (ListV l)
| null l = ""
- | otherwise = (intercalate ";" $ map (escapesemi . toString) l) ++ ";"
+ | otherwise = (intercalate ";" $ map (concatMap escapesemi . toString) l) ++ ";"
where
- escapesemi = intercalate "\\;" . split ";"
+ escapesemi ';' = "\\;"
+ escapesemi c = [c]
genDesktopEntry :: String -> String -> Bool -> FilePath -> Maybe String -> [String] -> DesktopEntry
genDesktopEntry name comment terminal program icon categories = catMaybes
@@ -82,7 +80,7 @@ buildDesktopMenuFile d = unlines ("[Desktop Entry]" : map keyvalue d) ++ "\n"
writeDesktopMenuFile :: DesktopEntry -> String -> IO ()
writeDesktopMenuFile d file = do
- createDirectoryIfMissing True (parentDir file)
+ createDirectoryIfMissing True (takeDirectory file)
writeFile file $ buildDesktopMenuFile d
{- Path to use for a desktop menu file, in either the systemDataDir or
@@ -136,7 +134,9 @@ userConfigDir = xdgEnvHome "CONFIG_HOME" ".config"
userDesktopDir :: IO FilePath
userDesktopDir = maybe fallback return =<< (parse <$> xdg_user_dir)
where
- parse = maybe Nothing (headMaybe . lines)
+ parse s = case lines <$> s of
+ Just (l:_) -> Just l
+ _ -> Nothing
xdg_user_dir = catchMaybeIO $ readProcess "xdg-user-dir" ["DESKTOP"]
fallback = xdgEnvHome "DESKTOP_DIR" "Desktop"