Skip to content

Commit

Permalink
Merge pull request #9 from r900/enhancement/use_xdg_base_dirs
Browse files Browse the repository at this point in the history
Enhancement/use xdg base dirs
  • Loading branch information
csfore authored Jun 23, 2024
2 parents 53dd0ac + 90dc0ab commit 059123c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/gentodo/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
from gentodo import bugs

OLD_PATH = os.path.expanduser("~/.local/share/todo/todo.json")
STORAGE_DIR = os.path.expanduser("~/.local/share/gentodo")
STORAGE_DIR = os.path.join(
os.getenv('XDG_DATA_HOME', os.path.expanduser("~/.local/share")),
"gentodo")
TODO_FILE = os.path.join(STORAGE_DIR, "todo.json")

class Gentodo:
Expand Down
8 changes: 5 additions & 3 deletions src/gentodo/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@
import os
import subprocess

STORAGE_DIR = os.path.expanduser("~/.config/gentodo")
CONFIG_FILE = os.path.join(STORAGE_DIR, "config.toml")
CONFIG_DIR = os.path.join(
os.environ.get("XDG_CONFIG_HOME", os.path.expanduser("~/.config")),
"gentodo")
CONFIG_FILE = os.path.join(CONFIG_DIR, "config.toml")

class Config:
'''Class to handle the configuration file settings'''
def __init__(self):
if not os.path.isfile(CONFIG_FILE):
os.makedirs(STORAGE_DIR)
os.makedirs(CONFIG_DIR)
with open(CONFIG_FILE, "w", encoding="utf_8") as config:
config.write("[gentodo]\n")
self.data = self.load_config()
Expand Down

0 comments on commit 059123c

Please sign in to comment.