User config files

Does anyone have a favorite cross-platform method for storing/retrieving per-user configuration options for their apps?

I can’t find it now, so I may have hallucinated it, but I thought I remembered seeing some functions in Racket for loading options from a standard file in the user's home directory.

I see there is an INI package that looks like it is actively maintained. There’s always the option to just read and write datums to a file but something more human-readable would be better.

One option is to use get-preference and put-preferences.

https://docs.racket-lang.org/reference/Filesystem.html#(def._((lib._racket%2Ffile..rkt)._get-preference))

2 Likes

The gui framework library has a preferences systems: 27 Preferences

There's also envy: Envy: An environment variable manager

1 Like

The framework library's preferences doesn't depend (at the module level) on any gui stuff and it builds on the racket/file operations to provide an API that is easier to deal with. It works well for DrRacket.

1 Like

In case of paths I tend to loosely follow the FreeDesktop's XDG spec and put config files inside ~/.config/APP-NAME, I believe on windows ~ either expands to C:\Users\USER\ or the special APPDATA directory.
The proper way would be to pick up XDG_CONFIG_HOME env var on Linux and APPDATA on Windows, then append to that the APP-NAME dir path.

In case of formats I had used either a special #lang, Racket data format (rktd) or JSON for my Racket projects.