Coder Social home page Coder Social logo

Comments (10)

kamiyaa avatar kamiyaa commented on May 20, 2024 1

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

from joshuto.

kamiyaa avatar kamiyaa commented on May 20, 2024

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?

from joshuto.

nilscript avatar nilscript commented on May 20, 2024

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.

from joshuto.

kamiyaa avatar kamiyaa commented on May 20, 2024

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

from joshuto.

Saul-Dickson avatar Saul-Dickson commented on May 20, 2024

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.

from joshuto.

kamiyaa avatar kamiyaa commented on May 20, 2024

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).

from joshuto.

nilscript avatar nilscript commented on May 20, 2024

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.

from joshuto.

kamiyaa avatar kamiyaa commented on May 20, 2024

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.

from joshuto.

kamiyaa avatar kamiyaa commented on May 20, 2024

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

from joshuto.

nilscript avatar nilscript commented on May 20, 2024

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());
}

from joshuto.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.