diff --git a/plugin/main.py b/plugin/main.py index 05238fd..3cf5767 100644 --- a/plugin/main.py +++ b/plugin/main.py @@ -140,6 +140,11 @@ def _steam_root(self): from ddsaves._common import deck_home return str(deck_home() / ".local/share/Steam") + def _theme_music_dir(self): + """Game Theme Music plugin cache; lives under the Steam user's homebrew, not necessarily /home/deck.""" + from ddsaves._common import deck_home + return str(deck_home() / "homebrew/data/SDH-GameThemeMusic/music") + async def ensure_blank_movie(self): """Положить assets/gh_no_startup.webm (0,2 с чёрного) в config/uioverrides/movies Steam; путь для настройки — /uioverrides/movies/gh_no_startup.webm (так его видит SteamClient.Customization.GetLocalStartupMovies).""" @@ -464,7 +469,7 @@ async def get_music_map(self): for appid, c in (self._hub_index().get("cards") or {}).items(): tid = (c.get("media") or {}).get("theme_id") if (isinstance(tid, str) and re.fullmatch(r"[A-Za-z0-9_-]{1,128}", tid) - and glob.glob(f"/home/deck/homebrew/data/SDH-GameThemeMusic/music/{glob.escape(tid)}.*")): + and glob.glob(f"{self._theme_music_dir()}/{glob.escape(tid)}.*")): out[appid] = tid return out @@ -474,7 +479,7 @@ async def get_music_files(self): return await asyncio.get_running_loop().run_in_executor(None, self._media().music_files) out = {} for appid, tid in (await self.get_music_map()).items(): - f = sorted(glob.glob(f"/home/deck/homebrew/data/SDH-GameThemeMusic/music/{glob.escape(tid)}.*")) + f = sorted(glob.glob(f"{self._theme_music_dir()}/{glob.escape(tid)}.*")) if f: out[appid] = os.path.basename(f[0]) return out diff --git a/plugin/py_modules/ddsaves/_common.py b/plugin/py_modules/ddsaves/_common.py index 2186e4a..cac5f3e 100644 --- a/plugin/py_modules/ddsaves/_common.py +++ b/plugin/py_modules/ddsaves/_common.py @@ -290,9 +290,23 @@ def finish(out: Dict[str, Any], path: Path) -> Dict[str, Any]: def deck_home() -> Path: - """Домашняя папка Деки: Decky может запускать бэкенд от root (HOME=/root), а сейвы лежат у deck.""" + """Домашняя папка Деки: Decky может запускать бэкенд от root (HOME=/root), а сейвы лежат у deck. + + Desktop Linux (non-Deck): Decky still runs the backend as root, but the Steam user is not + ``deck``. Fall back to the invoking sudo user, then to the single ``/home/*`` account that owns + a Steam installation, and only then to ``$HOME``.""" if Path("/home/deck").is_dir(): return Path("/home/deck") + sudo_user = os.environ.get("SUDO_USER") + if sudo_user and sudo_user != "root" and Path("/home", sudo_user).is_dir(): + return Path("/home", sudo_user) + try: + owners = [h for h in Path("/home").iterdir() + if h.is_dir() and ((h / ".steam/steam/steamapps").is_dir() or (h / ".local/share/Steam/steamapps").is_dir())] + except OSError: + owners = [] + if len(owners) == 1: + return owners[0] return Path(os.environ.get("HOME") or "/home/deck")