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

Include default configurations with released binaries #60

Closed
nilscript opened this issue May 23, 2021 · 10 comments
Closed

Include default configurations with released binaries #60

nilscript opened this issue May 23, 2021 · 10 comments
Labels
enhancement New feature or request

Comments

@nilscript
Copy link

nilscript commented May 23, 2021

Either create them in ~/.config/joshuto or have them in /etc/default/joshuto or some other directory.

@kamiyaa
Copy link
Owner

kamiyaa commented May 24, 2021

Could you clarify more on what needs to be done here?
Are you saying when we install, we should also install config files into ~/.config/joshuto or /etc/default/joshuto?

@nilscript
Copy link
Author

It's a matter of opinion where the configuration goes. Just so it's easy for the end user to create the default configuration somewhere. The best idea would be to behave like ranger and have a command for joshuto to create the default configuration or atleast copy it from somewhere to a suited directory.

I no longer think that ~/.config/joshuto or /etc/default/joshuto should be the install target for the configuration as ~/.config/joshuto is locked for one user and might be unaccessable to other users wishing to see the configuration and I did not understand fully what /etc/default was. Best directory to install the configuration would be /etc/joshuto as it is readable to anyone. An alternative to that would be /usr/share/joshuto.

@kamiyaa
Copy link
Owner

kamiyaa commented May 26, 2021

I think this would be better handled by package managers rather than the build tools.
However, we can potentially add functionality to tell joshuto to produce a sane default config.
ie.

~$ joshuto --generate-config <path>

which will generate a default config into given directory or or something like that

@Saul-Dickson
Copy link

Saul-Dickson commented May 29, 2021

In that case, how would joshuto remember where the configs are? I think an environment variable would work best for this.

Example: (.zshenv, .env, etc.)

export JOSHUTO_CONFIG_HOME="$XDG_CONFIG_HOME/joshuto"

Perhaps the --generate-config option could default to generation using this environment variable if the user doesn't include the <path> argument.

Of course, if the user doesn't have $JOSHUTO_CONFIG_HOME set, and doesn't include the <path> argument, there's a problem. This could be solved a couple of ways.

  • Hardcode a default value into joshuto, such as $XDG_CONFIG_HOME/joshuto
  • Output an error message to stdout.

The first option, I believe, is quite a bit more palatable.

@kamiyaa
Copy link
Owner

kamiyaa commented May 29, 2021

In that case, how would joshuto remember where the configs are? I think an environment variable would work best for this.

Example: (.zshenv, .env, etc.)

export JOSHUTO_CONFIG_HOME="$XDG_CONFIG_HOME/joshuto"

Perhaps the --generate-config option could default to generation using this environment variable if the user doesn't include the <path> argument.

Of course, if the user doesn't have $JOSHUTO_CONFIG_HOME set, and doesn't include the <path> argument, there's a problem. This could be solved a couple of ways.

* Hardcode a default value into joshuto, such as `$XDG_CONFIG_HOME/joshuto`

* Output an error message to stdout.

The first option, I believe, is quite a bit more palatable.

Joshuto currently already does this. See wiki/configuration

Joshuto is configured from files inside $XDG_CONFIG_HOME/joshuto (usually $HOME/.config/joshuto/ on GNU/Linux).

@nilscript
Copy link
Author

nilscript commented May 29, 2021

If $XDG_CONFIG_HOME is not set, it's default should always be $HOME/.config/. (I don't know why I didn't mention XDG directories. Must have forgotten. I hate having dotfiles in my home directory and programs which does not follow xdg user directories).
So to summarize so far the configuration should be searched in / created in these directories in ascending order:
--config <path> (with a config path argument that exits the program if path does not exist / not readable)
"$JOSHUTO_CONFIG_HOME/"
"$XDG_CONFIG_HOME/joshuto/"
"$HOME/.config/joshuto/"

The last entry should always exist on all known linux systems (Correct me if I'm wrong) which means that there is always a valid default to use.

@kamiyaa
Copy link
Owner

kamiyaa commented May 30, 2021

If $XDG_CONFIG_HOME is not set, it's default should always be $HOME/.config/. (I don't know why I didn't mention XDG directories. Must have forgotten. I hate having dotfiles in my home directory and programs which does not follow xdg user directories).
So to summarize so far the configuration should be searched in / created in these directories in ascending order:
--config <path> (with a config path argument that exits the program if path does not exist / not readable)
"$JOSHUTO_CONFIG_HOME/"
"$XDG_CONFIG_HOME/joshuto/"
"$HOME/.config/joshuto/"

The last entry should always exist on all known linux systems (Correct me if I'm wrong) which means that there is always a valid default to use.

Yea, we can do this.
It might require some major refactoring for the --config option because some of the configs are stored as global variables that are kind of hardcoded at compile time.
It will either require some changes to the loading of the configs, or make the configs not global, which requires a lot of changes elsewhere.

The other options should be fairly straightforward to implement though.

@kamiyaa kamiyaa added the enhancement New feature or request label May 31, 2021
@kamiyaa
Copy link
Owner

kamiyaa commented May 31, 2021

10f2eed: Added support for

  • $JOSHUTO_CONFIG_HOME
  • $HOME/.config/joshuto

If you strongly feel there is a need for --config or --generate-config, feel free to re-open this issue

@kamiyaa kamiyaa closed this as completed May 31, 2021
@nilscript
Copy link
Author

10f2eed: Added support for

* `$JOSHUTO_CONFIG_HOME`

* `$HOME/.config/joshuto`

If you strongly feel there is a need for --config or --generate-config, feel free to re-open this issue

It seams that you forgot to mention entry "$XDG_CONFIG_HOME/joshuto/" before closing.
You did add support for it with this code snippet?

if let Ok(dirs) = xdg::BaseDirectories::with_prefix(PROGRAM_NAME) {
    config_dirs.push(dirs.get_config_home());
}

@kamiyaa
Copy link
Owner

kamiyaa commented May 31, 2021

Yes, that is also implemented. I didn't mention it because it was already previously implemented

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants