Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions plugin/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)."""
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down
16 changes: 15 additions & 1 deletion plugin/py_modules/ddsaves/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")


Expand Down