import yaml
import os

CONFIG_FILE = "launcher_config.yaml"

def load_config():
    default_config = {
        "kiosk_mode": False,
        "silent_mode": True,
        "hide_mouse": True,
        "checksum_verification": True,
        "appimage_md5": "",
        "services": {
            "ethernet": True,
            "serial": True,
            "i2c": True,
            "vnc": True,
            "rtc": True,
            "bluetooth": False,
            "wifi": False
        },
        "pre_launch_commands": []
    }
    if os.path.exists(CONFIG_FILE):
        with open(CONFIG_FILE, 'r') as f:
            config = yaml.safe_load(f)
            return config if config else default_config
    return default_config

def save_config(config):
    with open(CONFIG_FILE, 'w') as f:
        yaml.safe_dump(config, f)