Skip to content

Commit

Permalink
evaluate XDG_CONFIG_HOME for CONFIG_DIR
Browse files Browse the repository at this point in the history
  • Loading branch information
r900 committed Jun 23, 2024
1 parent 6de3c72 commit 90dc0ab
Showing 1 changed file with 5 additions and 3 deletions.
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 90dc0ab

Please sign in to comment.