about summary refs log tree commit diff stats
path: root/fungus/constants.py
blob: 554c616cfd189b669d28f662df4022732800aaa8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/python3

import os
import subprocess

from pathlib import Path

from fungus.logger import get_logger
from fungus.path_manager import PathManager

log = get_logger(__name__)

fungus_version = "@VERSION@-@RELEASE@"

def get_desktop_dir():
    try:
        return subprocess.check_output(['xdg-user-dir', 'DESKTOP'], text=True).strip()
    except (FileNotFoundError, subprocess.CalledProcessError):
        log.warning("xdg-user-dir not found or failed; falling back to ~/Desktop")
        return str(Path.home() / 'Desktop')

# ── User config / data paths ────────────────────────────────────────────
fungus_launcher_dir = PathManager.user_config('fungus-launcher')
icons_dir = PathManager.user_config('fungus-launcher/icons')
config_file_path = PathManager.user_config('fungus-launcher/config.ini')
share_dir = PathManager.user_data()

app_dir = PathManager.user_data('applications')
fungus_png = PathManager.get_icon('fungus-launcher.png')

# ── Binary / runtime paths ──────────────────────────────────────────────
fungus_run = PathManager.find_binary('fungus-run')
fungus_proton_manager = PathManager.find_binary('fungus-proton-manager')
umu_run = PathManager.user_data('fungus-launcher/umu-run')

games_dir = PathManager.user_config('fungus-launcher/games')
games_json = PathManager.user_config('fungus-launcher/games.json')
prefixes_dir = PathManager.user_config('fungus-launcher/prefixes')
fungus_launcher_share_dir = PathManager.user_data('fungus-launcher')

# ── Computed paths ─────────────────────────────────────────────────────
desktop_dir = get_desktop_dir()

# ── Flags & defaults ────────────────────────────────────────────────────
fungus_backup = False


# ── Ensure required directories exist ───────────────────────────────────
os.makedirs(fungus_launcher_share_dir, exist_ok=True)
os.makedirs(fungus_launcher_dir, exist_ok=True)
os.makedirs(prefixes_dir, exist_ok=True)