Alpaca/src/internal.py

26 lines
662 B
Python
Raw Normal View History

2024-08-04 21:20:47 -06:00
# internal.py
"""
Handles paths, they can be different if the app is running as a Flatpak
"""
import os
2024-08-04 21:20:47 -06:00
APP_ID = "com.jeffser.Alpaca"
2024-08-04 21:20:47 -06:00
IN_FLATPAK = bool(os.getenv("FLATPAK_ID"))
def get_xdg_home(env, default):
2024-08-04 21:20:47 -06:00
if IN_FLATPAK:
return os.getenv(env)
2024-08-04 21:20:47 -06:00
base = os.getenv(env) or os.path.expanduser(default)
path = os.path.join(base, APP_ID)
if not os.path.exists(path):
os.makedirs(path)
return path
data_dir = get_xdg_home("XDG_DATA_HOME", "~/.local/share")
config_dir = get_xdg_home("XDG_CONFIG_HOME", "~/.config")
cache_dir = get_xdg_home("XDG_CACHE_HOME", "~/.cache")
source_dir = os.path.abspath(os.path.dirname(__file__))