frotz
frotz copied to clipboard
Figure out if/how to deal with XDG config file stuff
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 */
}
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
I think I'll wait on this for a while.
Aw, fair enough.