Skip to content

Allow macOS users to use XDG_CONFIG_HOME #78

Open

Description

@jcrben

The code here doesn't check for XDG_CONFIG_HOME if running macOS.

So I know that XDG is technically not a thing on macOS. But it is not uncommon for people to set up a similar system, using application-specific environment variables and at some level the XDG variables to accomplish the same thing.

For example, Git saves to the XDG_CONFIG_HOME if it is set on my Macbook.

It would be rather helpful for us if you did the same. It makes it easier for me to switch from macOS to Linux, which I want to be able to do easily.

Activity

  1. arusahni commented on Jan 22, 2017

    @arusahni

    Click does something similar for POSIX systems, although it doesn't try to infer the XDG_CONFIG_HOME directory. Instead it just returns a top-level ~/.appname dir for all platforms.

  2. arusahni commented on Jan 29, 2017

    @arusahni

    That looks like it'd apply that rule even when on Windows.

  3. xmo-odoo commented on Feb 20, 2018

    @xmo-odoo

    @arusahni I expect @rendaw means doing so when it's configured as darwin if you want/need to e.g.

    import appdirs
    if appdirs.system == 'darwin':
        appdirs.system = 'linux2'

    if you want your application to follow XDG rules even on OSX.

  4. DanCardin commented on Mar 8, 2020

    @DanCardin

    I honestly, it seems like it would be ideal if appdirs listened to XDG_*_HOME for all operating systems.

    Even if XDG isn't specified for macos, for almost all tools I can set (expecting it to work) XDG_CONFIG_HOME, and therefore I can commit that dir to my dotfiles. Now, any library which uses appdirs forces me to go back to using symlinks and yields a worse experience.

    In my mind, even if it doesn't make the most sense for someone to set it on windows, it at least gives everyone an opportunity to customize the config location, as opposed to unconditionally having it set to a specific location (but only on certain operating systems). And ultimately in the default case where it's not being set, you get the same existing behavior.

  5. 0az commented on Mar 20, 2020

    @0az

    I guess I can take a stab at a PR re-enabling XDG_CONFIG_HOME on Darwin next week.

    E: #137 exists.

  6. DanCardin commented on Mar 23, 2020

    @DanCardin

    #137 seems like it'd be a jarring breaking change, on new installations it'd always prefer ~/.config, hardcoded.

    I'm imagining

    def user_config_dir(appname=None, appauthor=None, version=None, roaming=False):
        path = os.getenv('XDG_CONFIG_HOME')
        if not path:
            if system == "win32":
                path = user_data_dir(appname, appauthor, None, roaming)
            elif system == 'darwin':
                path = os.path.expanduser('~/Library/Preferences/')
            else:
                path = os.path.expanduser("~/.config")
    
        # win32's user_data_dir already appends appname
        if appname and system != "win32":
            path = os.path.join(path, appname)
    
        if appname and version:
            path = os.path.join(path, version)
        return path

    Given my understanding of the reasoning for the way it is right now (XDG is only a thing for linux), then this seems ideal to me:

    • for people for whom that assumption is correct, they wont have XDG_CONFIG_HOME set and they'll see no change in behavior
      ** "Free" extra functionality for windows, where it's even less likely someone opts into thus, but hey i see no reason to artificially cripple windows.
    • for people like me, I'll see the behavior i want

    Probably ideally this pattern is applied to all the xdg variables, but truly config is the only one that I'd actually like to commit to a repo, and therefore the only one there's a significant incentive to fix.

    Happy to submit an actual PR if there's an indication it'd get merged.

  7. 0az commented on Mar 24, 2020

    @0az

    Happy to submit an actual PR if there's an indication it'd get merged.
    Unfortunately, we might have to wait for maintenance status to get sorted out in #79.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions