diff --git a/CHANGELOG.md b/CHANGELOG.md index d3789ef..661a170 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,4 +41,7 @@ * Added grep matches mode (kb grep "string" -m) * Fixed important bug in grep mode * Added sync mode - +0.1.7 (draft) + * Fixed grep bug with pull request 89 + * XDG Compliance: moving files to `$XDG_DATA_HOME/kb`, if it exists, and fall back + to `$HOME/.local/share/kb` if that environment variable does not exist diff --git a/kb/config.py b/kb/config.py index 1b5f140..66990e1 100755 --- a/kb/config.py +++ b/kb/config.py @@ -18,16 +18,18 @@ from pathlib import Path import toml +BASE_PATH = os.environ.get("XDG_DATA_HOME",Path(Path.home(),".local","share","kb")) + DEFAULT_CONFIG = { - "PATH_KB": str(Path(Path.home(), ".kb")), - "PATH_KB_DB": str(Path(Path.home(), ".kb", "kb.db")), - "PATH_KB_HIST": str(Path(Path.home(), ".kb", "recent.hist")), - "PATH_KB_DATA": str(Path(Path.home(), ".kb", "data")), - "PATH_KB_GIT": str(Path(Path.home(), ".kb", ".git")), + "PATH_KB": str(Path(BASE_PATH)), + "PATH_KB_DB": str(Path(BASE_PATH, "kb.db")), + "PATH_KB_HIST": str(Path(BASE_PATH, "recent.hist")), + "PATH_KB_DATA": str(Path(BASE_PATH, "data")), + "PATH_KB_GIT": str(Path(BASE_PATH, ".git")), # for future use - "PATH_KB_CONFIG": str(Path(Path.home(), ".kb", "kb.conf.py")), - "PATH_KB_TEMPLATES": str(Path(Path.home(), ".kb", "templates")), - "PATH_KB_DEFAULT_TEMPLATE": str(Path(Path.home(), ".kb", "templates", "default")), + "PATH_KB_CONFIG": str(Path(BASE_PATH, "kb.conf.py")), + "PATH_KB_TEMPLATES": str(Path(BASE_PATH, "templates")), + "PATH_KB_DEFAULT_TEMPLATE": str(Path(BASE_PATH, "templates", "default")), "DB_SCHEMA_VERSION": 1, "EDITOR": os.environ.get("EDITOR", "vim"), "INITIAL_CATEGORIES": ["default", ]