From f67af296baafd8d060501f82c87d75dd54f5e49c Mon Sep 17 00:00:00 2001 From: Ole <4692497+Guacam-Ole@users.noreply.github.com> Date: Thu, 26 Nov 2026 16:07:53 +0100 Subject: [PATCH] Deck: resolve the Steam user's home on desktop Linux, not only /home/deck deck_home() fell back to $HOME when /home/deck is absent, and main.py hard-coded /home/deck/homebrew for the Game Theme Music cache. On a desktop Linux install (Steam .deb, user is not "deck") the theme-music lookup could never match, and a backend started as root (HOME=/root) would find no library, prefix or save at all. deck_home() now tries, in order: /home/deck, the sudo invoker, the single /home/* account that owns a Steam installation, then $HOME. The theme music path is derived from it. Behaviour on a Steam Deck is unchanged. Co-Authored-By: Claude Fable 5.1 --- plugin/main.py | 9 +++++++-- plugin/py_modules/ddsaves/_common.py | 16 +++++++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) 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")