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

eg do not support XDG_CONFIG_HOME #77

Closed
mayanksuman opened this issue Aug 21, 2018 · 14 comments
Closed

eg do not support XDG_CONFIG_HOME #77

mayanksuman opened this issue Aug 21, 2018 · 14 comments

Comments

@mayanksuman
Copy link
Contributor

eg configuration is saved in ~/.egrc. I think eg should support XDG_CONFIG_HOME specification and save its configuration file in XDG_CONFIG_HOME.

@srsudar
Copy link
Owner

srsudar commented Aug 27, 2018

Is XDG_CONFIG_HOME an archlinux-only thing? I'm unfamiliar with it.

@mayanksuman
Copy link
Contributor Author

XDG_CONFIG_HOME is part of XDG directory structure, which is a new (quite old now) specification for unix like systems. The details are are available here.

Previously different program used to save the user configuration and data in $HOME folder. This specification tries to unclutter the mess, so that $HOME is more cleaner and config file and data file are having special folder for them.

@srsudar
Copy link
Owner

srsudar commented Oct 7, 2018

Sorry for the delay on this. I've been trying to decide what I think about it.

I wasn't familiar with XDG. Trying to get a sense for how widespread this it, it looks like git uses it, while it appears npm, ruby gems, and tmux have decided against it.

Do you know of other tools that do/don't use it? The npm issue says Chrome uses it, which is a pretty heavy hitter.

I respect the philosophy behind XDG, but I am somewhat hesitant to add (admittedly modest) complexity for what seems like a rather niche case. Certainly XDG users must have some way to support tools that don't look for the XDG directory? I run a symlink script when I install my dotfiles repo on a new machine. Without all tools buying into the XDG system, this step seems unavoidable. Keeping eg as one of them doesn't seem like a terrible thing to me. If I used XDG myself I might feel differently, of course.

Alternatively, people with XDG could just include an alias in their bashrc to have eg run with the config file flag pointing at their XDG directory.

The tmux issue above has 50 thumbs up to the idea of implementing XDG. If this was a popular request I could see including it. For now, I'm inclined to keep it as-is, reconsidering if it becomes a popular request.

I'm curious to hear what you think, though. Looking at those issues, people that use XDG seem to have pretty strong feelings about it. =)

@srsudar
Copy link
Owner

srsudar commented Mar 11, 2019

I'm rethinking my position on this, though I'm considering a slightly different implementation.

One thing I notice in your PR is that it looks like you are supporting both the XDG system and the defaults. For example if the XDG directory exists, but the XDG egrc doesn't exist, you still look in the default directory: ~/.egrc.

Is that the way XDG is supposed to work? I would have expected that you have either XDG or ~, not both. Is that incorrect? My first glance at the documentation didn't take an opinion, though I could have missed it.

@mayanksuman
Copy link
Contributor Author

mayanksuman commented Mar 12, 2019

Is that the way XDG is supposed to work? I would have expected that you have either XDG or ~, not both. Is that incorrect? My first glance at the documentation didn't take an opinion, though I could have missed it.

No, XDG is not supposed to work in tandem with ~. On contrary, it is designed to stop the practice of keeping the config/data file in ~.

I have submitted such PR, because, I wanted to maintain the backward compatibility for the users that have used eg in past and their config file is in ~. For them this PR will not break anything, but for new users the default XDG convention will be followed (i.e. XDG_CONFIG_HOME for config file).

@srsudar
Copy link
Owner

srsudar commented Apr 13, 2020

Sorry this has taken me so long. I wanted to take a different approach than you did so that I could write tests, but the tests are hard to understand. I'd write them differently if I was writing them now.

Can you take a look at this branch and see if it behaves like you expect? It did in my own messing around, but I'd love some confirmation.

@srsudar
Copy link
Owner

srsudar commented May 4, 2020

If anybody wanting this and using this directory structure could verify on the branch I mention above, I'd appreciate it. I'm hoping to include this in a release this week, and I'd appreciate a sanity check.

@BachoSeven
Copy link

I just had a look at the branch; I created an eg.conf in $XDG_CONFIG_HOME and it works as expected
I'm new to eg but I have two thoughts:

  • Thank you for trying to implement XDG specs. For those who try to use them it's very satisfying to find that a program tries to respect them.
  • As for the sanity check or simply my personal opinion, in my experience with configs in XDG_CONFIG_HOME, and also according to the actual specs, it seems like the most sensible choice is to have a subdirectory, meaning the file should be located at $XDG_CONFIG_HOME/eg/eg.conf. This also makes sense because I would store custom and/or examples there as well, making it a nicely packed directory for the program.

Let me know what you think!

@srsudar
Copy link
Owner

srsudar commented May 17, 2020

Yikes! Good point on the fact that there should be a subdirectory! I should have realized this, since I've begun using XDG in a few places on my linux machines, but I missed it.

Thank you so much for pointing it out!

I am inclined to leave it as ${XDG_CONFIG_HOME/eg/egrc rather than ${XDG_CONFIG_HOME}/eg/eg.conf, however. I don't see anything normative about the name of the actual config file in the spec you link to, and the summary here (see the notes column in the table at the bottom) shows some files that retain the rc name, like hg/hgrc for mercurial.

If I'm wrong about that, please let me know. I use XDG for i3 and rofi, and neither use the foo.conf syntax. Maybe I just have a biased sample, however.

In the meantime I'll make the change to a directory.

Thank you again for taking the time to check, I really appreciate it.

@srsudar
Copy link
Owner

srsudar commented May 17, 2020

Well I'm a doofus--I just realized that I had already changed it to eg.conf. I'm tempted to change it back to egrc... Hmm...

@BachoSeven
Copy link

By all means, egrc is much better!

@srsudar
Copy link
Owner

srsudar commented May 18, 2020

I just merged to master looking for ${XDG_CONFIG_HOME/eg/egrc. If you could check again that I'm right thinking it does what we discussed (it does when I try it), that'd be great.

Assuming so, I'll likely release a new version next month.

@BachoSeven
Copy link

Yes, everything works as expected. Thanks!

@srsudar
Copy link
Owner

srsudar commented Jun 7, 2020

This is now merged and released as of v1.2.0.

@srsudar srsudar closed this as completed Jun 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants