camdencheek / fre

Command line frecency tracking
MIT License
121 stars 8 forks source link

Use XDG state home rather than the data home. #21

Closed joshbode closed 1 year ago

joshbode commented 1 year ago

Currently, fre stores its default store (fre.json) in ${XDG_DATA_HOME}/fre (usually resolving to ~/.local/share/fre/fre.json).

However, the XDG Base Directory Specification suggests:

The $XDG_STATE_HOME contains state data that should persist between (application) restarts, but that is not important or portable enough to the user that it should be stored in $XDG_DATA_HOME. It may contain:

  • actions history (logs, history, recently used files, …)
  • current state of the application that can be reused on a restart (view, layout, open files, undo history, …)

Would it make sense to use ${XDG_STATE_HOME}/fre instead?

The reason I'm considering this question is that currently the --store option to fre specifies a path to an alternate store. My initial assumption when trying this was that just a name was required, and the storage location would be along-side the default store (e.g. --store=foo would resolve to ~/.local/share/fre/foo.json, rather than a file called foo in the current directory), so another possible improvement might be that if the value provided to --store is not an absolute path, it is assumed that the storage location should be in the same directory as the default store (wherever that is most appropriate) with --store=fre being synonymous with the default store.

I'm happy to make a PR if either of these (standard location or "named" stores) would be useful.

joshbode commented 1 year ago

Never mind - I have completely missed the --store_name option which does exactly what I'm asking for :) Also, I looked at the directories library and state_dir is Option<PathBuf> (not defined on Windows or macOS) so it wouldn't be a good choice.