Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Figure out if/how to deal with XDG config file stuff #40

Open
DavidGriffith opened this issue Feb 22, 2017 · 3 comments
Open

Figure out if/how to deal with XDG config file stuff #40

DavidGriffith opened this issue Feb 22, 2017 · 3 comments

Comments

@DavidGriffith
Copy link
Owner

DavidGriffith commented Feb 22, 2017

I'm not sure how I was planning to do things in src/curses/ux_init.c with XDG configuration. That is, if or how to put config files in $HOME/.config.

I put this chunk of code into the master branch near the top of os_process_arguments():

        if (getenv("XDG_CONFIG_HOME")) {
                snprintf(configfile, FILENAME_MAX,
                        "%s/frotz/frotz.conf", getenv("XDG_CONFIG_HOME"));
        } else {
                snprintf(configfile, FILENAME_MAX,
                        "%s/.config/frotz/frotz.conf", home);
        }

        if (!getconfig(configfile)) {
                snprintf(configfile, FILENAME_MAX, "%s/.frotzrc", home);
        }
    
        if (!getconfig(configfile)) {
                snprintf(configfile, FILENAME_MAX, "%s/frotz.conf", CONFIG_DIR);
                getconfig(configfile);  /* we're not concerned if this fails */
        }

While in ao-curses, it remained like this:

    /* First check for a "$HOME/.frotzrc". */
    /* If not found, look for CONFIG_DIR/frotz.conf */
    /* $HOME/.frotzrc overrides CONFIG_DIR/frotz.conf */

    strncpy(configfile, home, FILENAME_MAX);
    strncat(configfile, "/", 1);

    strncat(configfile, USER_CONFIG, strlen(USER_CONFIG));
    if (!getconfig(configfile)) {
        strncpy(configfile, CONFIG_DIR, FILENAME_MAX);
        strncat(configfile, "/", 1);    /* added by DJP */
        strncat(configfile, MASTER_CONFIG, FILENAME_MAX-10);
        getconfig(configfile);  /* we're not concerned if this fails */
    }
@escondida
Copy link
Contributor

Huh, I just noticed that that old XDG patch somehow got undone. Is there any plan to add it back? I'd be happy to make any changes you felt were necessary.

If this is still an "if" rather than a "how", personally my vote would be a strong "yes" to XDG dirs. I'll grant that they're awkwardly named, but any well-defined standard config directory is better than the ad-hoc solution of dotfiles

@DavidGriffith
Copy link
Owner Author

I think I'll wait on this for a while.

@escondida
Copy link
Contributor

Aw, fair enough.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants