septum
septum copied to clipboard
[Feature] Use XDG directories for config files on Linux
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).
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:
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.
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.
Might not be needed: Ada.Environment_Variables.Value does the job.
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";