29 lines
1.1 KiB
Python
29 lines
1.1 KiB
Python
"""Shared filesystem locations. Works whether run from the repo or ~/.config."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
from pathlib import Path
|
|
|
|
BASE_DIR = Path(__file__).resolve().parent
|
|
BACKEND_DIR = BASE_DIR / "backend"
|
|
STYLE_DIR = BASE_DIR / "style"
|
|
|
|
CONFIG_DIR = Path(os.environ.get("XDG_CONFIG_HOME", Path.home() / ".config")) / "astro-menu"
|
|
CACHE_DIR = Path(os.environ.get("XDG_CACHE_HOME", Path.home() / ".cache")) / "astro-menu"
|
|
# User settings live under XDG_STATE_HOME, NOT CONFIG_DIR: the config-updater does
|
|
# `rm -rf ~/.config/astro-menu` on every deploy, which would wipe pinned favourites
|
|
# and quad toggles. The state dir is never touched by config sync.
|
|
STATE_DIR = Path(os.environ.get("XDG_STATE_HOME", Path.home() / ".local" / "state")) / "astro-menu"
|
|
|
|
SETTINGS_FILE = STATE_DIR / "settings.json"
|
|
CONFIG_FILE = STATE_DIR / "config.json"
|
|
|
|
APP_ID = "eu.abdelbaki.astromenu"
|
|
|
|
|
|
def ensure_dirs() -> None:
|
|
CONFIG_DIR.mkdir(parents=True, exist_ok=True)
|
|
CACHE_DIR.mkdir(parents=True, exist_ok=True)
|
|
STATE_DIR.mkdir(parents=True, exist_ok=True)
|