-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Properly support XDG Base Directory Specification #6
Comments
@simonmar commented some time ago:
|
Clearly, we cannot simply chnage Or providing a function that returns |
@nomeata I'm afraid deprecating If we have to deprecate the current Isn't there a way to modify How did other Linux software manage the migration from pre-XDG to XDG-style per-user application data directories? |
That would be possible as well, and might be good enough. I think its also what other programs do, unless they actually move one directory to the other (which programs using this function could do as well, of course) |
I believe any change to |
Does XDG apply for many/most of the programs using this? Isn't XDG primarily for GUI apps? |
@zeckalpha while the XDG directory specification was pioneered in the GUI world, many daemons and command-line tools use it too. It's especially useful for managing application data vs. configuration. @hvr How do you feel about a new function I'm traveling the next few days which means I'll have some free time in the evenings to work on this if you need help. I like the idea of |
@pjones |
@hvr In that case I think it should be: dir <- getAppUserDataDirectory appName
return (dir </> appName) for consistency. An alternative to using the |
What is if I have two different environments for one application. On has set the XDG Base Directory an one hast not. Maybe the application would conduct different in this case and the solution will be better to split these functions in XDG based functions and not XDG based functions and the user of this library should decide for he's own if he uses the XDG based functions or not. The other way is to make this decision in the library itself e.g. getAppUserDataDirectory appname = do
dir <- lookupEnv "XDG_DATA_HOME"
case dir of
Nothing -> do
home <- getEnv "HOME"
return $ home ++ '/' : '.' : appname
Just path -> return $ path ++ '/' : appname IMHO this should be the base decision of this discussion. |
I just became aware of the related Xmonad Issue 484: Use XDG Base Directory Specification (which links also back here) |
I don't think new OS conventions would appear so rapidly as to be a problem. I also don't think there's a way to implement this in a backward-compatible manner: changing the location will cause surprises for both developers and end-users downstream. If we do add a new function, We could add the following functions:
and perhaps some utility functions for obtaining various search paths:
However, I don't know if we should add all of them right away since not all of them are necessarily in demand. (Do people even use |
This addresses issue haskell#6 in a backward-compatible way by adding a new function that conforms to the XDG Base Directory Specification.
This addresses issue haskell#6 in a backward-compatible way by adding a new function that conforms to the XDG Base Directory Specification.
Fixed in ab9d081 (I did not implement the utility functions nor |
@Rufflewind I'm wondering, with the given operation, what's the recommended upgrade path for code currently using |
Note: I don't intend to deprecate Unfortunately, migrating is not as simple as tweaking the code:
Ultimately, the hardest part is performing the migration correctly :\ Edit: this comment has been updated to use the new two-parameter API instead of the previous one-parameter API, as suggested by hvr's comment below |
I think any guidance we can give via the documentation helps users (to avoid having everyone having to figure it out for themselves individually, as well as reducing the risk of mistakes) bikeshed-warning Looking at your last example, I wonder if there are any cases where you want the base-folder returned by
rather than having the slightly more convenient form
which would encode the policy that you're expected to refer to an app-specific subfolder in the respective Xdg-base-folder... (and if you deliberately pass the empty string or |
I agree the latter is more convenient. I picked the former because it felt simpler and didn't make any assumptions as to what the user intended to do with it. However, I think passing an empty string to get the base directory is reasonable as long as it's documented behavior. For |
I couldn't decide between the different implementations of dropWhileEnd and takeWhileEnd from https://ghc.haskell.org/trac/ghc/ticket/9623#comment:7, so I choose the simplest solution using two times reverse instead of foldr. See also: https://www.haskell.org/pipermail/libraries/2014-September/023835.html
directory
provides a functiongetAppUserDataDirectory :: String -> IO FilePath
which on Linux simply constructs the resulting path as${HOME}/.${APPNAME}
.However, that doesn't conform to the XDG Base Directory Specification
Further reading:
The text was updated successfully, but these errors were encountered: