lord63 / tldr.py

A python client for tldr: simplified and community-driven man pages.
MIT License
186 stars 18 forks source link

Support XDG base directory specification #9

Closed sethwoodworth closed 8 years ago

sethwoodworth commented 8 years ago

It would be really cool if tldr supported the XDG base directory specification arch wikidebian wiki. In this case, the .tldrrc file would move to ~/.config/tldrrc (in linux). The tldr repo would probably go in .local/share/tldr. There is a python package called appdirs that will provide these values for you on at least osx or linux if you're interested!

lord63 commented 8 years ago

Wow, I don't know that before. Thanks for letting me know that :)

Currently, we just put the configuration file in the user home directory by default, might be a bit dirty. You can specify the tldr repo anywhere in the configuration file(repo_directory). You can put it under ./local/share/tldr if you want.

The reason why I put it under the user home directory is:

If we change the default configuration file to $XDG_CONFIG_HOME, we need:

questions:

Seems like not a very easy task to support this with just modify a few lines of code. Any ideas?

Shir0kamii commented 8 years ago

I'll try to make the changes since I would have prefered these installation directories by default. I'll open a PR when they'll be ready for discussion.

lord63 commented 8 years ago

@Shir0kamii Thanks for your kind! :)

Currently, I'm for the currently implementation, maybe a bit dirty but less code and less complexity.

For anyone who interested in this topic, I'll let this issue open and please feel free to leave your comments here. We haven't made the final decision yet.

lord63 commented 8 years ago

@Shir0kamii @sethwoodworth Hi, just came out an idea. How about that:

  1. first, try to read the configuration directory from an environment variable, for example, TLDR_CONFIG_DIR.
  2. if None, we use user's home directory as the default directory home.

In this situation, only a few lines of code should be enough :)

benefits:

problems:

Shir0kamii commented 8 years ago

Maybe we can add a third step :

  1. try to read the configuration directory from TLDR_CONFIG_DIR.
  2. try to read the configuration directory from XDG_CONFIG_HOME.
  3. if None, we use user's home directory as the default directory home.

Does it makes sense to you ?

We could also make use of the user data directory to store the pages and index and avoid asking the tldr's page's path. That's just an idea though.

lord63 commented 8 years ago

@Shir0kamii No need for a third step, in my opinion. If you feel ok with the configuration file at the home directory, nothing needed form you; if you want to change the default location, set the environment variable TLDR_CONFIG_DIR.

lord63 commented 8 years ago

@Shir0kamii @sethwoodworth Just create a PR to support custom the config directory, have a look! If it is ok, I'll release a new version soon.

Shir0kamii commented 8 years ago

@lord63 The XDG_CONFIG_DIRECTORY is part of the XDG specification and that's why I think it should be supported. But it should be tried after TLDR_CONFIG_DIR to allow a maximun of flexibility. Hence my proposition.

I looked at #16 and adding this third step should be easy with the implementation you chosen.

lord63 commented 8 years ago

@Shir0kamii Yes, just one line code should be enough. The reasons why I don't support it are:

$XDG_CONFIG_HOME defines the base directory relative to which user specific configuration files should be stored. If $XDG_CONFIG_HOME is either not set or empty, a default equal to $HOME/.config should be used.

But tldr.py already take the user's home directory as the default one. If we fellow the spec and change it to $HOME/.config, this change will be incompatible. So we can't follow the spec .

so, the current PR can let you follow the XDG Base Directory Specification(need some work from the users), and compatible for older users. The patch is simple and solves the problem.

Any ideas?

lord63 commented 8 years ago

v0.4.0 supports custom the configuration file via TLDR_CONFIG_DIR, you can point it to the folder you like, e.g. /home/lord63/.config/tldr/. Close it now.