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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# Now playing: games on the Dashboard's music card
## Goal
While a game runs, on the PC or on the Xbox, the Dashboard's music card shows
the game instead of the track. When no game runs it is the music card as
before.
## Sources
- **PC** (new module `deckit/modules/games.py`): Steam, PCSX2 and DuckStation.
- **Xbox**: the existing `xbox` module's `playing`, `session` and `titles`.
## PC detection
`hyprctl clients -j` on each state read (the card polls every 5s).
- Class `steam_app_<id>`: Steam game `<id>`.
- Class `pcsx2-qt`: PS2. Class `duckstation-qt`: PS1. Only when the window
title is not the bare emulator name (`PCSX2`, `DuckStation`), which is the
idle game list.
First match wins; one game at a time.
## PC game data
Steam (root `~/.local/share/Steam`):
- name: `steamapps/appmanifest_<id>.acf` `name`, in each library listed by
`steamapps/libraryfolders.vdf`; fallback the window title.
- cover: `appcache/librarycache/<id>/library_600x900.jpg`.
- total minutes: `userdata/*/config/localconfig.vdf`, the app's `Playtime`.
Emulators (PCSX2 `~/.config/PCSX2`, DuckStation `~/.local/share/duckstation`):
- name: the window title.
- serial: the `cache/gamelist.cache` entry whose title equals the window
title (the cache stores path, serial, title as strings in a row).
- cover: `covers/<serial>.jpg` (or `.png`).
- total minutes: `playtime.dat` line `<serial> <seconds> <last played>`
(PCSX2 keeps it in `inis/playtime.dat`).
Any of these missing or unparsable leaves that field empty. No error card.
## State
`/api/games`:
{"playing": null}
{"playing": {"platform": "steam|ps1|ps2", "name": "...", "cover": "/api/games/image/<key>"|null,
"minutes": <total before this session>|null, "session": <unix start>}}
`session` is the time deck-it first saw the game (same rule as Xbox). A cover
is served at `/api/games/image/<key>` for the current game only, so the
tablet never names a path.
## Card
`static/modules/music.js` `update(st, el)` keeps the music view. The
dashboard passes it a game when one runs, picked in this order: PC game, Xbox
`playing`. For Xbox: name from `playing.name`, cover and minutes from the
`titles` entry with the same id, `session` from the state.
Game view: cover, name, platform badge (Steam, PS1, PS2, Xbox), session time
ticking client side, total = minutes + session. Music controls hidden.
The dashboard polls `games` every 5s and `xbox` every 30s, each only when its
module is enabled.
## Out of scope
Achievements, FPS/GPU stats, launchers other than Steam, PCSX2, DuckStation.
## Tests
`tests/test_games.py`: fake `run` for hyprctl and a temp tree with an acf,
libraryfolders.vdf, localconfig.vdf, gamelist.cache bytes and playtime.dat.
`node --check` on changed JS.
|