Closed jn64 closed 1 year ago
well that makes it kinda useless.
for storing documents the "config" dir is wrong, we dont want hidden configuration files here. the fallback is basically the same as VCV Rack btw
so if I understood this right we need to basically:
XDG_CONFIG_HOME
is set, fallback to $HOME/.config
if not$_CONFIG_DIR/user-dirs.dirs
and try to parse it without errorsXDG_DOCUMENTS_DIR
inside it if available, otherwise fallback to $HOME/Documents
(or maybe use localization to find fallback docs path, but that becomes too much)That sounds correct. I found more info here: https://freedesktop.org/wiki/Software/xdg-user-dirs/
For application code the hope is that the various desktops will integrate this and have a nice API to find these directories.
I don't know if there are such APIs or if they'll be useful to you. It seems like other projects implement it themselves, although on a closer look, JUCE assumes ~/.config
, which I guess is wrong. wxWidgets seems to have a correct implementation.
(I think the whole thing is stupid, but as a user I can either use the stupid thing to get what I want, or not get what I want...)
both of those implementations don't bother to check for #
that would make something a comment, or duplicated env vars where the last one is what should end up being used, or prefixes added to the var like PLEASE_IGNORE_XDG_DOCUMENTS_DIR=/not/this/one
.
both seem to use an awful way for parsing, no error checking done at all besides checking if the folder exists...
that at least makes it easier on our side, as the bar is quite low for a quick and dirty implementation
Quick and dirty will do IMO. If the user has a malformed file, other things will break before they get to Cardinal.
I think you can just exec xdg-user-dir DOCUMENTS
to get the correct directory path
yes, but exec within a plugin is frowned upon as it duplicates file descriptors and other things. anyway the parsing of the file is not that complex
It seems like Cardinal is looking for the env var
XDG_DOCUMENTS_DIR
:https://github.com/DISTRHO/Cardinal/blob/a51cb460bc958b60c7b40c0d27943a136fe1f49b/src/CardinalCommon.cpp#L497-L500
XDG_DOCUMENTS_DIR
is not a known env var in the XDG basedir spec (unlike sayXDG_CONFIG_HOME
)I think this was mistakenly taken from
user-dirs.dirs(5)
.XDG_DOCUMENTS_DIR
is a variable only used inside the user-dirs.dirs file, not an env var. This file is meant to be sourced by shell scripts. I know of some programs (e.g. JUCE) parse this file to get the various user folders.The result is that Cardinal is looking in
~/Documents
, even though my documents folder is~/docs
: