septum icon indicating copy to clipboard operation
septum copied to clipboard

[Feature] Use XDG directories for config files on Linux

Open onox opened this issue 3 years ago • 5 comments

Is your feature request related to a problem? Please describe. septum init creates a file .septum/config in the current working directory, but I would like to create it relative to the home directory.

Describe the solution you'd like When Septum tries to create .septum/config in the home directory, it should instead store it relative to $XDG_CONFIG_HOME. If this environment variable is not defined, it should have the value $HOME/.config. Thus the full path becomes $HOME/.config/septum/config.

Similarly, cache files (don't know if Septum has any) could be relative to $XDG_CACHE_HOME (which is by default $HOME/.cache).

onox avatar Jan 02 '22 18:01 onox

I can try to implement this if you can tell me how to tell Septum to create the file in the home directory instead of the current working directory :slightly_smiling_face:

onox avatar Jan 02 '22 18:01 onox

Maybe there should be a crate for doing this? This isn't part of the Ada standard lib and I ran across similar code in Alire yesterday to do this.

pyjarrett avatar Jan 02 '22 19:01 pyjarrett

I think it's just a matter of using Ada.Command_Line.Environment?

Edit: hmm, maybe it's a good idea to create a crate for it.

onox avatar Jan 02 '22 20:01 onox

Might not be needed: Ada.Environment_Variables.Value does the job.

onox avatar Jan 02 '22 20:01 onox

So it's something like this:

Env_Home           : constant String := Ada.Environment_Variables.Value ("HOME", "~");
Env_XDG_Config     : constant String := Ada.Environment_Variables.Value ("XDG_CONFIG_HOME", Env_Home & "/.config");
Septum_Config_Path : constant String := Env_XDG_Config & "/septum/.config";

onox avatar Jan 02 '22 20:01 onox