Skip to content

Commit

Permalink
Added Compliance to the XDG Specification as specified in Pull Reques…
Browse files Browse the repository at this point in the history
…ts/Issues #84 and #87
  • Loading branch information
gnebbia committed Jun 21, 2021
1 parent 77629b6 commit 57d65df
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 10 additions & 8 deletions kb/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", ]
Expand Down

0 comments on commit 57d65df

Please sign in to comment.