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

Better adhere to XDG specification #180

Open
skipkayhil opened this issue Apr 8, 2020 · 3 comments
Open

Better adhere to XDG specification #180

skipkayhil opened this issue Apr 8, 2020 · 3 comments

Comments

@skipkayhil
Copy link

Spec for reference

Currently, any package that uses update-notifier results in an update-notifier-<package>.json being put in $XDG_CONFIG_HOME.

As someone who symlinks my $XDG_CONFIG_HOME into my dotfiles repository, this leads to undesired behavior. These are not files that I want in my dotfiles, nor do I think they would be useful to keep in sync across multiple devices. I believe the data stored here would be more appropriate in $XDG_DATA_HOME or $XDG_CACHE_HOME

@sindresorhus
Copy link
Member

I agree. Should be “data”, not “cache”.

@skipkayhil
Copy link
Author

I can create a PR for this, do you have a recommended way to do it? The simplest is probably passing in the new configPath to configstore.

@jmromer
Copy link

jmromer commented Nov 5, 2021

This would be a welcome addition. I think XDG_STATE_HOME would make more sense, however, since this data isn't portable across machines (as would be expected with XDG_DATA_HOME), but also isn't entirely non-essential (as with XDG_CACHE_HOME):

The $XDG_STATE_HOME contains state data that should persist between (application) restarts, but that is not important or portable enough to the user that it should be stored in $XDG_DATA_HOME. It may contain:

actions history (logs, history, recently used files, …)

current state of the application that can be reused on a restart (view, layout, open files, undo history, …)

{
	"optOut": false,
	"lastUpdateCheck": 1634843835359,
	"update": {
		"latest": "8.1.0",
		"current": "6.14.11",
		"type": "major",
		"name": "npm"
	}
}

There's a node library that abstracts away most of the logic: https://www.npmjs.com/package/xdg-basedir

Happy to submit a PR for this if there's still support for it.

import {xdgData, xdgConfig, xdgDataDirectories} from 'xdg-basedir';

console.log(xdgData);
//=> '/home/sindresorhus/.local/share'

console.log(xdgConfig);
//=> '/home/sindresorhus/.config'

console.log(xdgDataDirectories);
//=> ['/home/sindresorhus/.local/share', '/usr/local/share/', '/usr/share/']

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