banzai-cli icon indicating copy to clipboard operation
banzai-cli copied to clipboard

Support XDG directory standard

Open sagikazarmark opened this issue 4 years ago • 9 comments

Is your feature request related to a problem? Please describe. Cool kids keep their home directories clean.

Describe the solution you'd like to see Support loading configuration from $XDG_CONFIG_HOME.

Describe alternatives you've considered This is the way. No alternatives.

Additional context Should probably wait for spf13/viper#1048

sagikazarmark avatar Jan 07 '21 09:01 sagikazarmark

  • "If $XDG_CONFIG_HOME is either not set or empty, a default equal to $HOME/.config should be used."
  • Load config from $BANZAICONFIG file, or from the first directory existing of
    • (maybe $BANZAI_CONFIG_HOME)
    • $XDG_CONFIG_HOME/banzai
    • $HOME/.banzai
  • Create new config dir in $XDG_CONFIG_HOME

orymate avatar Jan 07 '21 12:01 orymate

The correct (detailed) order is:

  • BANZAI_CONFIG_HOME (if we want to support it)
  • $XDG_CONFIG_HOME/banzai
  • $HOME/.config/banzai (new default, fallback if $XDG_CONFIG_HOME is not defined)
  • $HOME/.banzai (for backward compatibility)

sagikazarmark avatar Jan 07 '21 12:01 sagikazarmark

I would stick to using $HOME/.config/banzai only if XDG_CONFIG_HOME is not set.

orymate avatar Jan 07 '21 12:01 orymate

That's exactly what the above means. (And that's why I emphasized the order)

sagikazarmark avatar Jan 07 '21 13:01 sagikazarmark

That's exactly what the above means. (And that's why I emphasized the order)

Not really. We shouldn't check $HOME/.config/banzai if a different XDG_CONFIG_HOME is set, but there is no banzai config there.

orymate avatar Jan 07 '21 13:01 orymate

Why not?

sagikazarmark avatar Jan 07 '21 18:01 sagikazarmark

Why not?

Because the referenced xdg standard defines it this way.

orymate avatar Jan 08 '21 08:01 orymate

No. It only says what should be the fallback if the relevant env var is not defined. Nothing says we can't use it otherwise.

But determining a location for writing a config for the first time is tricky (even without this search entry)

sagikazarmark avatar Jan 08 '21 09:01 sagikazarmark

No. It only says what should be the fallback if the relevant env var is not defined. Nothing says we can't use it otherwise.

Yes, and that's the only difference between the two lists in the first two comments on this issue...

orymate avatar Jan 08 '21 09:01 orymate