import json
import os
from pathlib import Path

CONFIG_FILE = Path.home() / "config.json"


def load_config():
    """Load configuration from JSON file"""
    try:
        if CONFIG_FILE.exists():
            with open(CONFIG_FILE, "r") as f:
                return json.load(f)
    except Exception:
        pass
    return {"chdman_path": ""}


def save_config(config):
    """Save configuration to JSON file"""
    try:
        with open(CONFIG_FILE, "w") as f:
            json.dump(config, f)
        return True
    except Exception:
        return False
