Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Be more standards-compliant about .klog/ folder location #250

Closed
jotaen opened this issue Feb 13, 2023 · 0 comments · Fixed by #251
Closed

Be more standards-compliant about .klog/ folder location #250

jotaen opened this issue Feb 13, 2023 · 0 comments · Fixed by #251
Labels
ENHANCEMENT Ideas and feature requests

Comments

@jotaen
Copy link
Owner

jotaen commented Feb 13, 2023

Currently, klog stores the .klog/ folder in the user’s home directory – i.e., ~ on UNIX, and C:\Users\yourname on Windows. That might not be the most appropriate location, though:

  • On Linux, people might prefer ~/.config or something else
  • On macOS, there is no clear standard. Apple suggests ~/Library/Application Support, but I think that’s primarily targeted at GUI apps. CLI apps tend to use ~/ or ~/.config.
  • On Windows, app config usually goes where ever %AppData% points to

So before releasing the config file with a half-hearted and home-baked lookup mechanism, it’s now a good time to revise this topic. For consideration:

  • $XDG_CONFIG_HOME (from the freedesktop directory standard) is mostly a thing for Linux, but it’s also not universal there.
  • There is Go’s os.UserConfigDir. The underlying proposal doesn’t seem well thought-through, however, especially in regards to macOS.
  • I eagerly added KLOG_FOLDER_LOCATION to allow users to override the general config location with a klog-specific path. Apart from the clunky name, I’m not 100% sure this is needed: one the one hand, there is no unanimous and universal standard for storing config files, so an app-specific override might come handy; on the other hand, such fine-granularity might be superfluous and unnecessarily complicated.

Changing the config location will be a breaking change, and users might have to relocate their bookmarks.json file (if exists).

@jotaen jotaen added the ENHANCEMENT Ideas and feature requests label Feb 13, 2023
@jotaen jotaen changed the title Be more standards-compliant about .klog/ folder Be more standards-compliant about .klog/ folder location Feb 13, 2023
jotaen added a commit that referenced this issue Feb 17, 2023
Resolves #250.

The lookup order for klog’s config folder (previously referred to as
“klog folder”, residing at `~/.klog` by default on all OS’es) is now
this:

- macOS:
- `$KLOG_CONFIG_HOME` (expects full path including the “suffix” bit, so
you can also set it to be `/foo/bar/all-my-klog-configs` if that fancies
you)
- `$XDG_CONFIG_HOME/klog` (for XDG-addicts that stranded on macOS for
some reason)
- `$HOME/.klog` (the default / most “idiomatic” config location on
macOS)
- Linux:
  - `$KLOG_CONFIG_HOME` (see above)
  - `$XDG_CONFIG_HOME/klog`
- `$HOME/.config/klog` (the default / most “idiomatic” config location
on Linux)
- Windows
  - `%KLOG_CONFIG_HOME%` (see above)
- `%AppData%\klog` (the default / most “idiomatic” config location on
Windows)

klog iterates through these respective locations, and the first env var
that’s set wins. klog will look for (and potentially initialise) the
config folder at that location.

By doing `klog --config-folder`, you can see which one it chose, and it
also prints the lookup order for reference – e.g., on macOS:

```
$ klog --config-folder
/Users/jan/.klog
(Lookup order: $KLOG_CONFIG_HOME, $XDG_CONFIG_HOME/klog, $HOME/.klog)
```

For the env var name, I eventually settled on `KLOG_CONFIG_HOME`, as I
find that most clear and straightforward.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ENHANCEMENT Ideas and feature requests
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant