OpenPrinting / libcups

OpenPrinting CUPS Library Sources
https://openprinting.github.io/cups/cups3.html
Apache License 2.0
28 stars 15 forks source link

XDG Base Dir Compliance #43

Closed maddovr closed 1 year ago

maddovr commented 3 years ago

Would it be possible to move the configuration inside .cups into ~/.config/cups? This would help keep our home directory clean and it should be the way to go in the future.

michaelrsweet commented 3 years ago

~/.config is specific to Linux. And CUPS has used ~/.cups since v1.2 (where it moved from ~/.lpoptions).

maddovr commented 3 years ago

~/.config is specific to Linux. And CUPS has used ~/.cups since v1.2 (where it moved from ~/.lpoptions).

It is actually not. While the initiative did indeed start from freedesktop.org (the spec here), it is respected by most unix operating system like the BSDs due to the fact that many such OS run linux-compatible programs.

Matthew-Beckett commented 3 years ago

~/.config is specific to Linux. And CUPS has used ~/.cups since v1.2 (where it moved from ~/.lpoptions).

It is actually not. While the initiative did indeed start from freedesktop.org (the spec here), it is respected by most unix operating system like the BSDs due to the fact that many such OS run linux-compatible programs.

Apologies for chiming in, but is there any actual benefit in doing this? Are we simply arguing the semantics of configuration being stored in ~/.cups vs ~/.config/cups? If so, by virtue of using ~ to resolve the user's home is that not already XDG base path compliant?

Furthermore, I don't think relying on a spec which is only officially implemented in Linux distributions is safe for ensuring compatibility on non-Linux distributions despite most implementing this specification.

eli-schwartz commented 3 years ago

https://ploum.net/207-modify-your-application-to-use-xdg-folders/

Every OS has its platform-specific preferred location for:

It's actually a very valued end user feature to be able to treat application data differently depending on what it's used for. You don't want to check caches into git, or waste time syncing them to daily backups. You don't want anything else to get accidentally deleted as useless. You don't want to check data into git, but you do want to be able to diff and follow the evolution of config settings in git.

XDG defines these for linux. Windows uses %APPDATA% and similar. MacOS puts this into locations within ~/Library

I don't know what the *BSDs do, I don't think they get quite as much attention and as far as I can tell they don't officially bless anything... So since the macOS and Windows standards are not applicable to BSD I suspect most programs that implement this for the other OSes just lump BSD in with linux on this. It's certainly not harmful as long as it's consistent.

jessebot commented 1 year ago

I'd love to see this feature, so adding a quick thought on this:

XDG Base Dir Spec is useful also so that users can configure the following variables, not just to ~/.config, but anything they like:

export XDG_CONFIG_HOME="$HOME/.config"
export XDG_CACHE_HOME="$HOME/.cache"
export XDG_DATA_HOME="$HOME/.local/share"
export XDG_STATE_HOME="$HOME/.local/state"

Then it's up to applications to honor those variables, so that the user can have their files, consistently, where-ever they'd like. I use both Debian and macOS every day and I utilize XDG variables to have cross platform locations where each config/cache/state is stored. This also helps with keeping your dot files in a git repo, because you can clone the same repo across Linux and macOS and not have to do a bunch of hacky linking. Individual applications have different ways of solving this, but many support (or are working to) support it. A common compromise is to have shell env vars like for directories, so in the case of cups, you could have things like:

Then have those variables always default to the old school location, so that no past users are confused, but modern users have some choice.

This list shows different apps and how they have implemented this feature. I recently noticed that less is on there, so I figured I'd come check on cups and see what the current status was. Cups is on there, but currently links to this issue.

Thank for keeping cups open and maintained all these years. 🙏