User:Suzanne.soy/Data storage: RFC


 * 1) FreeCAD should honour the XDG Base Directory Specification
 * 2)  for configuration files, i.e. most of
 * 3)  for any data that can be deleted and regenerated offline, and caches of things which normally require network access at the moment when they are browsed, so most likely  and
 * 4)  for fonts, icons etc. which are usable by multiple applications. It is the equivalent of  ( is  by default). FreeCAD already stores some things related to the Qt online help browser in
 * 5) There are some recommendations about other directories namely  (portable libraries)  (arch-specific libraries) and  (executable libraries) A few tools (1, 2) use the directories other than.
 * 6)  defaults to
 * 7) It is unclear what the difference between  and  is:
 * 8) This page on tldp.org says that plug-ins live in ,
 * 9) this page on tldp.org says that "The "share" word is used because what is under /usr/share is platform independent, and can be shared among several machines across a network filesystem",
 * 10) this page at freedesktop.org says that  is for "Static, private vendor data that is compatible with all architectures" and that  is for "Resources shared between multiple packages, such as fonts or artwork.".
 * 11) The directories other than  are not customisable using env vars.
 * 12) Macros and mods (currently in  and ), when they are installed by the Addon manager, should be in  or in.
 * 13) Which one to pick depends on whether we consider these "plug-ins" usable by other tools or whether they are private (which could likely be understood as "FreeCAD-specific"). Branded versions of FreeCAD can share installed macros and mods; and external applications could invoke FreeCAD macros directly (see e.g. how the XternalApps Workbench invokes Inkscape extensions from within FreeCAD, the reverse would also make sense). Also, since  is not customisable, it seems less useful to move things there (maybe it is a recent )
 * 14)  defaults to  and is a list of places where fonts, icons etc. are stored.  shouldn't be hard-coded based on the  (assuming that's the case), instead (or probably in addition to that) a lookup should be done in all the directories listed in this colon-separated variable.
 * 15)  as the default location when opening/saving files on a fresh installation (probably already the case, I didn't pay attention; the  is probably an okay choice especially when started from the command-line)
 * 16) "State" as described on the Debian wiki and in this mailing list message is the kind of small values that an application remembers (window position, size of the Tree View, recently used files) which can usually change often (so it is not a good candidate for storing alongside the configuration in a VCS, or at least not for storing in the same repository), and tends to be created without the user making conscious choices or without realising that these are "settings" (as opposed to actual configuration, which happens e.g. in the preferences editor and involved clicking on checkboxes and making actual choices). There is no standard location for state, and no XDG variable to customise that location; however it seems like a good idea to keep that information in a separate sub-directory of the FreeCAD configuration directory. Currently some of these details are stored in separate files (e.g. cookies in, the window size in  instead of
 * 17) FreeCAD should honour the  variable
 * 18) When FreeCAD is started for the first time, it should not create any directories or files in the user's home folder, unless some customisation or state change actually happens. Rationale: if the user is just trying FreeCAD and simply creates a new document, then exits without saving, they do not expect this to cause any change in the "settings" or "configuration" of their machine. Since FreeCAD has a start page, any "first run" wizard or tip can be integrated in the start page and be displayed every time. This has the advantage that the software operates in a more stateless way: instead of switching between different states, unbeknownst to the user, the software looks and feels like it was started from the first time every time, unless the user actively configures something (e.g. through a start page customisation dialog). State (like the window size or toolbar positions or browser history) can be saved, but only if the user does an action that changes the default state (toggles maximisation of the main window, moves a toolbar, or visits a browser page other than the start page).

Python macros and mods can use some of these paths via the following API, which might need to be extended:

Related:
 * Open ticket: https://tracker.freecadweb.org/view.php?id=2956
 * https://forum.freecadweb.org/viewtopic.php?f=4&t=49028&start=10#p421716
 * https://wiki.freecadweb.org/Talk:Start_up_and_Configuration#Related_forum_posts