Centralize constants
This commit is contained in:
parent
72ad571ff2
commit
a4da1ddd73
5 changed files with 24 additions and 19 deletions
|
|
@ -2,6 +2,8 @@ import json
|
|||
from dataclasses import dataclass, field
|
||||
from pathlib import Path
|
||||
|
||||
from constants import DEFAULT_CONFIG_PATH
|
||||
|
||||
|
||||
@dataclass
|
||||
class Config:
|
||||
|
|
@ -11,13 +13,9 @@ class Config:
|
|||
injection: dict = field(default_factory=lambda: {"backend": "clipboard"})
|
||||
|
||||
|
||||
def default_path() -> Path:
|
||||
return Path.home() / ".config" / "lel" / "config.json"
|
||||
|
||||
|
||||
def load(path: str | None) -> Config:
|
||||
cfg = Config()
|
||||
p = Path(path) if path else default_path()
|
||||
p = Path(path) if path else DEFAULT_CONFIG_PATH
|
||||
if p.exists():
|
||||
data = json.loads(p.read_text(encoding="utf-8"))
|
||||
if any(k in data for k in ("daemon", "recording", "stt", "injection")):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue