Skip to content

Architecture

Couchdogs is built on open-source projects, each picked on merit and credited (ADR 0011). Gamescope drives the TV, our runner starts the apps, our pad daemon owns the pads, and our own Moonlight server, built from Wolf's protocol code, streams a screen of its own to each remote device (ADR 0012, design). Closest comparison: LibreELEC (Kodi plus a minimal system, built to be a TV box). It ships as a Docker Compose stack the user runs; fixes are applied inside our containers, never by editing the host (ADR 0004).

Layers

Layer What Owner
TV Gamescope as DRM master on HDMI; the shell and one container per app run inside it as X11 clients; the runner puts one in front; padd feeds the pads into the app in front (ADR 0009, 0013). Absent when the host has no TV (ADR 0032): then every screen is a remote device's, and a host pad is ignored Couchdogs (Gamescope from Valve, pads with inputtino)
Remote streaming Our server (stack/server/): Moonlight protocol, announced on the LAN over mDNS so Moonlight lists it by itself, a headless Gamescope screen per device from the runner, VAAPI or NVENC encode, pads through padd (ADR 0012, 0015). Its serverinfo answers before pairing with a <Couchdogs> element, so the client (below) can tell a Couchdogs host from a plain Sunshine or Wolf one (M8) Couchdogs (protocol code from Wolf, credited)
Client The Couchdogs client (client/, M8b, ADR 0040): moonlight-qt and moonlight-android plus a small patch series that lists Couchdogs servers first, pairs with Moonlight's own PIN and opens the server's "Couchdogs" app on a cold start. One install per platform; stock Moonlight stays unmodified beside it and still reaches every host. The first desktop start copies an existing v0.1.0 pairing and settings once, reading (never changing) the old store v0.1.0 kept: stock Moonlight's on macOS and Linux, the portable Moonlight Game Streaming Project/Moonlight.ini beside the exe on Windows, which ships the same portable zip. The copied client identity makes the server see both apps as one device. CI (.github/workflows/client.yml) applies the series and builds Windows, macOS, Linux and Android on client-v* tags, attaching each release the source tarball of that exact build; the LAN page links one release for all four Couchdogs (Moonlight, GPLv3, patched and credited)
Apps Our own images on our own base (stack/images/): ES-DE with emulators, Plex HTPC, Jellyfin Desktop, YouTube (VacuumTube), Steam Big Picture (in its own nested Gamescope, ADR 0021) Ours, install methods credited to Wildlife (Games on Whales); our config overlays
Shell Couchdogs home screen, store, pairing screen; on the TV's Gamescope in our Servo kiosk. Each remote device gets a shell of its own on its own screen Couchdogs
Host integration Restart policies (the TV comes back by itself), Bluetooth pairing backend, Home Assistant hooks (the runner's control API), memory limits Couchdogs

How a frame reaches the TV

App (e.g. Dolphin) or the shell, X11 client in its own container
  -> Gamescope in screen-tv (shared /tmp/.X11-unix volume)
  -> KMS/DRM on the GPU's HDMI -> TV

No encode, one compositor. A remote client (phone, handheld) gets its own headless Gamescope: our server captures it, encodes it and the device decodes. A device can also join the TV (M6c), or another device's screen (ADR 0025): its stream then shows that screen and its pad is another player there. The TV can join a device too (M6c step 2): a viewer app on the TV shows that screen's picture and sound, read from its PipeWire on the same machine, and the TV's pads play there.

Target

TV:      Gamescope on HDMI (ADR 0009) -- shell (Servo kiosk) + one container per app
Remote:  our Moonlight server (ADR 0012) -- own headless Gamescope per device, or join the TV
Pads:    one daemon grabs every pad and feeds a virtual pad into the app in front (ADR 0013)
Voice:   the remote's mic over BlueZ, transcribed on the CPU and typed through the runner (ADR 0042)
Apps:    recipes started by our runner, with memory caps (ADR 0013)

No encode for the TV, one compositor per screen, one app ("Couchdogs") in every Moonlight client. The TV part is built (M5), remote screens too (M6a), and joins both ways and shared-screen control (M6c steps 1 to 3). A host with no TV has no TV part at all (ADR 0032). Design and open questions: own-core design.

The stack (stack/)

Piece What
compose.yml docker compose up -d starts the TV (screen-tv, shell), runner, padd, voice typing (voice) and our Moonlight server for remote devices. With no TV, ./couchdogs setup adds compose.no-tv.yml to COMPOSE_FILE; it puts screen-tv, shell and voice in a profile nothing switches on (ADR 0032, 0042), so the other five start and nothing waits on a display. An override, not a profile in this file, so an older .env keeps its TV. Runtime services name ${IMAGE_PREFIX}couchdogs-<x>:${IMAGE_TAG} (the published images by default); a viewer service holds the viewer image so docker compose pull fetches it
compose.build.yml Clone only (COMPOSE_FILE=compose.yml:compose.build.yml): the image builds (*-image, profile build, tags couchdogs-<x>:local), never started by up (stack/images/README.md)
rom-aliases Maps ROM folder names from other schemes (RomM, Batocera, full names) to ES-DE system names; each folder is mounted read-only under its ES-DE name, never renamed
images/base/ Hooks baked into the images (nothing is mounted from the repo at run time). 40-couchdogs-udev.sh prepares /run/udev for padd (below); an app's own hooks (the Dolphin config 50-couchdogs.sh was one) are baked into its image in the store repo (ADR 0030)
shell/ The home screen (ADR 0010): kiosk/ is our Servo browser (Rust), built by compose's shell-image service into couchdogs-shell:local. server.py (Python standard library) serves web/ on 127.0.0.1 inside the shell container and passes the page's calls to the runner (POST /api/home puts the shell back in front without stopping anything). The page works with a pad or a TV remote, and its bottom line (on the charcoal, light key chips) shows the pad button and remote key for each action: arrows move, A / OK opens or resumes, Start / Menu opens Options (Open or Resume, then Stop when running or Uninstall when not, which asks the same card as the Store), B / Back closes a card. The header has the logo on its warm white block, flush with the screen's left edge, with the page's icon and name (Home, Store, Join, Settings, or Setup in the wizard) inside the same block, and on the right the inputs and the clock. While someone watches this screen the header also shows an eye and the count left of the inputs; the eye, the inputs and the clock share one look (the clock's grey and size, round battery bars); a click or tap opens the Join page on its "Watching your screen" row (never a pad target: the Join tile is the pad's way there). Starting shows a card (icon, name, sliding bar) until the runner says the app is shown, polling every 500 ms, with an error card after 60 s; Back on it goes Home and leaves the app running. While an app is in front the pads go to that app, so on a pad the Home button (Guide) is the way back. A stopping tile fades with a spinning ring until the app is gone. A page change (and each setup step) comes in with a 0.2 s fade and rise of the page and its header name; nothing moves once it is in, and prefers-reduced-motion turns every transition off. A launch that needs room asks in the same kind of card. A Moonlight device waiting to pair raises a PIN card on the home screen (never over another card or an app): four digits, Up/Down change one, Left/Right move, and a row "What is it?" with Handheld, Phone, Tablet, Laptop and PC (the router's name first when it has one) as chips side by side: Right past the last digit reaches the row, Left/Right walk it, Up goes back to the digits; A sends both through POST /api/pair to the server's pair socket, B hides it until the device stops waiting; the card closes when the device gives up. On a remote device's own shell (M6c, ADR 0025) the home has one "Join" tile just before the Store, shown while there is a screen to join or someone watching this screen and badged with how many of both: A opens a Join page in the Store's tiles, one row headed "Screens", the TV first and then the other devices, each with its icon, its name as text (never markup), a chip saying what plays there or "Home", and, for a device that disconnected, "Left N min ago" (its screen keeps running for SCREEN_IDLE_MINUTES). A opens that screen's card: Join, Close; joining posts /api/join and within a second the device sees that screen, Home on its pad (or Back held 1 s) brings it back. Below the screens a second section, "Watching your screen", lists who watches this screen (the TV while it shows it, then the devices joined to it), and A opens " is watching this screen." with Stop sharing first and Close: Stop sharing posts /api/unshare and the page redraws from the runner's answer, so the screen goes back to whoever was watching nothing (M6c). The TV's own home shows the device screens with a picture on the same page, and A shows one on the TV; its watchers are the devices joined to it. The page follows the home poll (no endpoint of its own) and closes when both lists empty. One copy per app (ADR 0027): a launch refused because the app runs on another screen answers 409 with the runner's busy block unchanged, which the page turns into a card " is open on " with "Join " when busy.join, and Close (no "open here"; own still goes back to /api/launch for a copies: many app, which no recipe uses yet). Every home's options live on the Settings page (ADR 0029), the last tile on every home (our icons/settings.svg): A opens one column of rows, drawn from every home poll. Devices (on every home: device shells get the pair socket too, so any home also shows the PIN card; a device's page starts with "This device" and its own name) lists the paired devices (on a device's page its own entry comes first, noted "This device", from the home's device id) and opens one's card, Rename (the same five kinds) or Forget behind a confirm ("Forget ? It must pair again."); Others can join this screen is that screen's own setting (a toggle through POST /api/settings {joinable}; off hides the screen from other devices' Join page and ends the joins on it); every page holds Sign-in code too (the code big, the page's address, a countdown, ADR 0031); every page holds Group apps by kind, Clock (24-hour or 12-hour; the header clock on every screen follows it) and Voice search (shown once the voice service has had a remote with a mic ready, or a language is picked; its card says what the mic does and holds toggle chips, one per Whisper code, none picked reading "Any language"; the voice service's list), all through POST /api/settings (a change is toasted on every other live home: "Handheld set the clock to 12-hour"). The rows run in the owner's order: connecting things (Devices, Bluetooth, Sign-in code), then this screen (Resolution, Others can join this screen), then the household's preferences (Clock, Group apps by kind, Voice search), then Help & about. The room card names where each app runs ("Steam on the TV has to close first"). Every other message is a centred OK card too (the app's icon when there is one, the reason in small text): errors, a broken recipe the first time it shows, the apps or the Store failing to load (once, not per poll; the apps card closes itself once they load again, so a runner restart leaves nothing to dismiss). The household's "Group apps by kind" (off by default, ADR 0029) groups the home and the Store alike: Watch, then Play, each under its heading, then the Store, Join and Settings tiles on their own line; the runner gives every home app its recipe's kind for this. The page is exactly one screen tall: the header and the bottom bar stay put and only the grid scrolls, following the focused tile. Nothing is drawn between the tiles and the bottom bar; an empty home or Store says so in dim text across the grid. All runner text reaches the page through textContent. Icons: apps keep their own full-colour icons; Couchdogs features (Home, Store, Join, Settings, the header's eye) are line icons (4 px round stroke, no fill, light on tiles, navy on the logo's block), so an app and a feature never read alike. The Store (M7a) is the second to last tile on every home (our icons/store.svg): A opens a page with the home's own tiles (icon, name) in one grid (Up/Down move a line), each installed app with an "Installed" chip in the Running colour (nothing on one that is not) and other chips only for what needs a look (Update, Waiting, % with a bar while it builds, or Failed); A opens the app's card (icon, name, about line, a "This app can use" list (the household folders it mounts, the GPU and sound, any loosened sandbox with its why), then size and state; the size is the image's real size once installed, the recipe's estimate before, shown as "about N GB": Installing % with the build step, or Failed with the last log line) with what the state allows (Install, Update or Retry first; Uninstall when the image is here, Close selected when it is installed), so nothing installs in one press; Options on a tile whose image is here (Installed, Update, or a failed update) asks "Uninstall ? Its settings and saves stay." (Uninstall or Keep, Keep selected), and B goes home. <code>/api/store</code>, <code>/api/store/install</code> and <code>/api/store/remove</code> pass the runner's answers through (202 queued, 409 while it runs, 507 no disk space), and the page polls the store once a second only while it is open, draws each tile's icon from <code>/api/store/icon/<id></code> (the runner's verified cache, ADR 0030), and shows the runner's <code>store_error</code> as one dim line when the last fetch failed. First run (M7c): until <code>/api/household</code> says there is no wizard (any non-200 means none), the page opens a five-page wizard by pad (welcome, Watch, Play, phone or laptop, Install; A picks or goes on, B goes back) that posts <code>/api/household/wizard</code> with the picked ids only; zero picks just finishes it, and with picks it ends on the Store, where the installs show. The phone or laptop page says where the household page is and that the sign-in code is in Settings on any screen (ADR 0031). The Settings page holds "Sign-in code": A opens a card with the code big ("123 456"), a QR code of the page's address with that code in the fragment, the page's address and a thin countdown for the minute, which asks <code>/api/household/code</code> every 5 s and as the minute ends while it is up (that is what keeps the window a typed code works in open); A and B close it, X "Sign out every browser" asks nothing more, the card says "Every browser must sign in again." for a few seconds and every other live home gets a toast naming who did it. A sign-in spends the code it used (<code>last_login</code> in <code>household.json</code>): every home with the card open closes it and says "Signed in from a browser" for a few seconds, since the digits it shows would no longer work (ADR 0031 amendment). The QR is drawn by Nayuki's QR Code generator, vendored in <code>qrcodegen.js</code> (credits), as an SVG data URL in an <code><img></code>: SVGs as images draw in Servo, inline <code><svg></code> does not. <code>/api/household</code>, <code>/api/household/code</code>, <code>/api/household/signout</code> and <code>/api/household/wizard</code> pass to the runner with status and body unchanged; there is no login here, every home is the TV in the room or a paired device. <code>screen-entry.sh</code> starts both and restarts the kiosk when it exits. Every transient note goes to the status pill through <code>POST /api/notify</code> (ADR 0033: "Signed in from a browser", and the runner's own notices), so no card is left open for news; the interactive cards stay (the pairing PIN, the sign-in code). Settings ends with a Help & about row on every home (a chevron, the version as its value) that opens a legend card, with the version this install runs and the LAN page's address when the runner can tell it below the gestures: key chips beside plain words (Guide held for Home or to leave a screen you joined, Select alone held 1 s and Esc alone held 1 s on a keyboard the same as Guide, A and B open and back, Start for Options), the same on every home and naming no device kind. Rows that open a page or card (Devices, Bluetooth, Sign-in code, Voice search, Help & about) end in a chevron and the hint says Open; the others say Change. Motion is short and cheap, transform and opacity only: tiles scale on focus and dip under a press, cards fade and pop in and fade out again, rows and items change colour, and nothing animates while the page is still</td> </tr> <tr> <td><code>screen/entry.sh</code></td> <td>One screen (image <code>couchdogs-screen:local</code>): starts PipeWire, WirePlumber and pipewire-pulse as root in <code>/run/couchdogs</code> (the TV's <code>couchdogs-tv-run</code>, a device screen's <code>couchdogs-screens/<device>/run</code>, both open to uid 1000 in the app containers), sets the default sink, then runs Gamescope. <code>couchdogs-input</code> (<code>input.py</code>, ADR 0028) runs in Gamescope's child with a respawn loop (a run shorter than 5 s doubles the wait, to 60 s), which also keeps the session up: it injects XTest mouse, scroll, key and touch events into that screen's Xwayland for the server's datagrams (<code>/run/couchdogs/input.sock</code>), and draws the pointer Gamescope does not capture, in a click-through overlay window shown only while relative motion arrives. The socket has a reader thread of its own and everything that touches X runs on one worker thread (the kernel refuses a send when ten datagrams wait, so the daemon must never be slow to <code>recv</code>; the queue between them is bounded at 512 and drops the oldest moves, never a held button or key). <code>couchdogs-overlay daemon</code> (ADR 0033) runs beside it in the same Gamescope child: the screen's one status pill, drawn with the art module <code>pill.py</code> (the same one the server's baked PNGs and the viewer use), taking JSON notices on <code>couchdogs-overlay.sock</code> in the screen's run directory (the runner sends one datagram per toast, join or hold, so there is no process per notice). It fades and slides in, fills a hold's meter from the start message and its duration, and unmaps its window when nothing shows (after drawing one empty frame: Gamescope keeps an unmapped overlay's last buffer on screen), so Gamescope never has an idle animation to draw. Where a notice shows depends on the screen (ADR 0036): on the TV the window is on HDMI, and Gamescope, rebuilt with a second patch (<code>capture-without-overlay.patch</code>), leaves the overlay out of its PipeWire capture, so a device that joined the TV never sees the TV's notices; a device screen maps no window and writes each pill frame to <code>couchdogs-overlay.frame</code> in its run directory instead (removed when nothing shows), which only that device's own stream reads and blends in (<code>stack/server/src/notice_frame.{hpp,cpp}</code>). A third patch (<code>pipewire-still-screen.patch</code>, ADR 0035) gives a reader that joins a still screen a frame at once, and every reader one at least once a second (unpatched, a TV joining an idle device kept its old picture until the device's screen changed). The daemon draws no cursor: Gamescope draws its own pointer on the TV's HDMI output (<code>-C 3000</code> hides it after 3 s still), but its PipeWire capture has none, so the server draws the pointer into a device's stream (ADR 0028). Each device's gesture, held keys, held buttons and scroll remainder are kept apart by the datagram's device id (X's own buttons and keys are shared by the two). On the TV (<code>screen-tv</code>, backend <code>drm</code>) that is DRM master on the connected output of <code>DRI_CARD</code> (or <code>TV_KMS_CONNECTOR_NAME</code>) with <code>SOUND_CARD</code>'s HDMI as the sink. Its size is <code>picture-size</code> in the run directory when the runner wrote one the TV offers (Settings > Resolution, ADR 0034), else <code>TV_RESOLUTION</code>; it writes the size it runs (<code>tv-size</code>) and the connector's modes (<code>tv-modes</code>) back there for the Settings row. A remote device's screen (<code>SCREEN_BACKEND=headless</code>, started by the runner, M6a) has no output and no sound card: Gamescope's headless backend takes the client's <code>SCREEN_RESOLUTION</code> and <code>SCREEN_FPS</code>, and the default sink is a <code>couchdogs</code> null sink the server captures. It does get the GPU's card node beside the render node, because headless Gamescope still creates its Vulkan device from a primary node and aborts without one (<code>CARD_NODE</code>, defaulting to <code>DRI_CARD</code>); it takes no DRM master, so the TV keeps its output. The shell and the apps are X11 clients in their own containers through the screen's X11 volume; Gamescope's Xwayland admits only root, so its child runs <code>xhost +si:localuser:#1000</code> for the apps (refused, SDL falls back to an offscreen window: sound, no picture)</td> </tr> <tr> <td><code>web/</code></td> <td>The household LAN page (M7c): <code>web.py</code> (stdlib HTTP, runs in the runner image with the shell code mounted for <code>RunnerShell</code> and <code>PairSocket</code>) and <code>static/</code> (plain HTML, CSS, JS). It lists the store's apps as tiles (the icon from <code>/api/store/icon/<id></code>, behind the sign-in code; ADR 0031), with the recipe's <code>uses</code> line, the runner's <code>store_error</code> as one line and the state and action on the tile; it pairs a device through a card that is the first on the page only while one waits (a quiet line in Devices otherwise). Devices also carries Get the app (M8b): one client download (<code>CLIENT_RELEASES_URL</code>, default our releases) for Windows, macOS, Linux and Android beside stock Moonlight's page, then lists, renames and forgets the paired devices, runs the wizard and puts signing out every browser at the bottom, away from the everyday cards. One column on a phone; from 900 px the store takes the wide column and Devices sits beside it. A screen's card also carries the page's address with the code in the fragment (<code>#code=123456</code>), so a scan signs in at once: the page takes the fragment out of the address before it posts the code (signed in already, it only takes it out), also when a scan lands in a tab that has the page open, and keeps it nowhere. The store tiles are redrawn only when the store changed, so the poll does not fetch every icon again. Behind it: every request asks the runner <code>POST /household/session</code>, so a sign-out ends every session; five wrong codes from one address lock it for 60 s (429, in memory, bounded; tries in flight count, so parallel tries cannot slip past). Only a Host that is an IP address, <code>localhost</code> or a name in <code>WEB_URL</code>/<code>WEB_HOSTS</code> is served (421 otherwise, against DNS rebinding). It pairs a device (the pair socket; its form asks what the device is, like the TV's PIN card, ADR 0029), drives the store, runs the first-run wizard (the picked apps only), lists, renames and forgets paired devices (<code>/api/devices</code>, <code>/api/devices/rename|forget</code>, the pair socket's own commands; with no TV this is a way to forget a lost device) and signs out every browser (<code>/api/signout</code>). Its Type box (ADR 0038) picks a screen (<code>/api/typing</code>: the TV, then open device screens; hidden with none) and sends text, or one key of Back, the arrows, Backspace and Enter, through <code>POST /api/type</code> to the runner's <code>/type</code>, which hands it to that screen's <code>couchdogs-input</code> socket as text ops in 32-character pieces (a newline is Enter; at most 500 characters; nothing typed is logged). A Bluetooth section (ADR 0038) lists, pairs and forgets the host's pads, remotes and keyboards the way the TV's Settings card does (<code>GET|POST /api/bluetooth</code>, signed in only; an address is a request key, never shown, and a device BlueZ named only by its address shows its kind). A hidden tab asks for nothing: no scan while it is in the background, and it scans at once when it is shown again.. Compose service <code>web</code>, port <code>WEB_PORT</code> (8970, ADR 0022), 128m, no Docker socket; the only LAN-facing container on the <code>couchdogs-pair</code> volume. Every POST must be <code>application/json</code> (415) and at most 16 KiB; the page is served with <code>X-Frame-Options: DENY</code> and <code>default-src 'self'</code></td> </tr> <tr> <td><code>runner/</code></td> <td>The runner (ADR 0013): starts one container per app from the store's verified index (<code>storeindex.py</code>, ADR 0030: a recipe comes from a signature-checked cache, never from the repo) (own images, memory cap, household folders from <code><NAME>_DIR</code> in <code>.env</code>, extra privileges only through a recipe's <code>security</code> block), installs and removes apps for the Store (<code>install.py</code>: the index entry decides what an install is, because CI copies a recipe as written and a published app keeps <code>couchdogs-<id>:local</code> and its <code>store.build</code> name; a published app's digest image is verified with cosign and its <code>couchdogs.source</code> label matched to the index before it is tagged <code>couchdogs-<id>:local</code>, a <code>redistribute: false</code> app is one build at a time from the index's cached folder with the host's default buildx builder (ADR 0020's amendment: its layers go straight into Docker's image store, so nothing is exported and loaded again, and the base is a local image <code>couchdogs-installer-base:local</code> labelled with the base folder's hash, which is what says it is current), and a launch never pulls, ADR 0020, 0030). One store index and one installer serve the whole household, device runners included, and the fetch runs on its own thread (a minute after a failure, then every ten), so no request and no screen waits on the internet, keeps every app it starts within <code>COUCHDOGS_MEM_BUDGET</code> (a launch that does not fit offers to stop the oldest app), and puts the shell or an app in front through Gamescope's X11 root properties. An app nobody has seen for 10 s is frozen with Docker's cgroup freezer (ADR 0037). Seen means in front of a screen somebody sees: the TV's own screen always, a device screen while its device streams it, another device joined it or the TV views it. So every app behind a front is frozen, and so is the front of a device screen whose device left. Its playback and downloads pause, its memory, pads and network sessions stay, and everything that makes it seen or touches it (bringing it to front, the device coming back, a join, the TV viewing that screen, a join ending, a stop) unfreezes it first, before the stream's first frame. A runner restart finds frozen apps in Docker and knows a device still streams from the server's 1 s source poll; the home's badge says "Paused" for them. For a remote device (M6a, <code>screens.py</code>) it starts a headless Gamescope and a shell of that device's own, both mounting the shared <code>couchdogs-screens</code> volume by Docker volume subpath (<code><device>/x11</code>, <code><device>/run</code>, which needs Docker Engine 26+ and is the only thing that asks for API 1.45; the TV stays on 1.43). The shell joins the compose network, because its page calls the runner by its service name; focus on the screen runs <code>xprop</code> through <code>docker exec</code>, because the runner has no device screen's socket mounted. A screen container gets the GPU's render node and its card node (headless Gamescope aborts without a primary node, see <code>screen/</code>), and one that exits before its node is up is answered at once with its exit code logged, instead of polling a stopped container for thirty seconds. With <code>GPU_VENDOR=nvidia</code> (ADR 0023) every container that gets the GPU (apps whose recipe lists <code>gpu</code>, device screens, device shells) also gets Docker <code>DeviceRequests</code> for the NVIDIA Container Toolkit (<code>spec.gpu_requests</code>); otherwise the key is left out. Containers are found by their <code>couchdogs.screen</code> label and name, so a restarted runner or server reuses them (a device's shell on an older image than its tag is made again at the device's next connect, and a stopped screen on one at its next start; a running screen only when its device opens it again after leaving, with no app on it and nobody watching it, then it goes with its shell, since an app on it would lose its display), and a released screen, or one found running when the runner starts, is stopped (apps first, then shell, then screen; never removed) after <code>SCREEN_IDLE_MINUTES</code> unused, on its own loop so an idle stop never delays the TV's. A screen that stops by itself while its device still streams (Gamescope crashed) is started again within a second, so the device gets a home back and a leave from a join has a screen to return to. A device can join the TV or another device's screen (M6c, <code>Screens.join</code>; ADR 0025): the runner keeps who joined what, sends padd the whole map (<code>POST /joins</code>) on every change and once a second with each device screen's front, and answers the server's <code>GET /screens/<device>/source</code>, so either side restarting is back in step within a second. Home from that device's pad, the release of its screen, or the screen it joined stopping ends the join. A Home that ended a join to a screen with an app in front (not its shell) is noted once for that home, the TV's own included (every home is equal): it opens the shell's card "<App> is still running on <screen>" with "Close it" (that app, on that screen, a frozen one thawed first, and only the app the note names) and "Join again" (ADR 0033 amendment). The TV is offered (and a join accepted) only while its PipeWire publishes Gamescope's node, checked like a device screen's and cached 2 s, and a device screen only while it has a picture; otherwise <code>join</code> is empty and a join answers 409. Joining yourself, or a screen that is not there, is 400. Two devices may join each other: a device screen only ever shows its own apps, so there is no loop, and padd follows a second hop only through the TV. A screen opened with <code>"test": true</code> carries the <code>couchdogs.test</code> label and is never listed and never joined. The TV joins a device (M6c step 2, ADR 0018) through the viewer app <code>watch</code> (<code>viewer.py</code>): container <code>couchdogs-tv-watch</code> from <code>couchdogs-viewer:local</code>, 256 MB, no network, the TV's sockets plus the device's <code><device>/run</code> read-only, labelled like an app plus <code>couchdogs.watch=<device></code>. It shows the same status pill a device on the TV sees, drawn by the same art module (<code>stack/images/screen/pill.py</code>) through <code>server/brand/make_marker.py</code> with the handheld glyph and "On <device name>" (<code>WATCH_NAME</code>): the pill for 3 s, then the join ring alone (a 48 px ring <code>view.py</code> fades down to the opacity the server rests it at), in the shell's logo block like every pill (two <code>gdkpixbufoverlay</code> elements; <code>view.py</code> runs the pipeline and crossfades their alpha in the server's steps, which <code>gst-launch</code> cannot). Its frames are stamped as read (<code>do-timestamp=true</code>): Gamescope gives every frame one timestamp, and any element that reads them (sink QoS, a text overlay) then drops all but the first, which froze the TV twice. The runner starts it without the memory room check and puts it in front, so window tagging, cleanup and Home when it exits work as for any app; whether the TV watches, and what, is read from that label, so a runner restart keeps it. The join list is one shape on every home, <code>join</code>: <code>[{screen, title, front_title, away_minutes}]</code>, the TV first on a device's own home (title "The TV") and the device screens after it, sorted by name, the device's own screen never in it; <code>away_minutes</code> is null while the device is connected and otherwise the whole minutes since it was released. A device screen is titled by its <code>couchdogs.name</code> label (the name the server sends in <code>POST /screens</code>, a renamed device's at its next connect, when the screen is free: the runner makes that screen again only when no app runs on it and nobody streams from it, remembering the rename otherwise, ADR 0029, control, format, private-use and unassigned characters removed, at most 64; else "Device" plus the id's last 4). The TV's home lists device screens with a picture, by their <code>couchdogs.name</code> label (the name the server sends in <code>POST /screens</code>, control, format, private-use and unassigned characters removed, at most 64; else "Device" plus the id's last 4), sorted by name. It never offers a device that joined the TV, a device cannot join the TV while the TV watches it (both 409), and a watched screen's idle deadline is pushed, as is that of a device screen another connected device has joined; "Left N min ago" counts from the owner's release (unknown, so not shown, for a screen found running after a runner restart). When the watched device disconnects with only its home on screen, the TV goes Home too and shows "<name> left" (nobody drives that screen, and its picture would sit still); with an app open there the TV stays on it and plays on. The viewer does not exit when the watched screen stops: the next pass sees that screen's container gone and brings the TV home (the viewer exiting does too); TV Home removes the viewer. Switching devices replaces the viewer under the launch lock, and a pass that does not hold that lock leaves a missing viewer alone. padd's map then also has <code>"tv": <device></code>. Who joined is shown, not managed (ADR 0027, amended for the last M6c item): every join or leave sends one toast to the joined screen, naming who came or went (a device's <code>couchdogs.name</code>, "The TV" for the TV). A Home that ends a join also toasts the leaver's own home "Left <screen>" (a quick Guide goes Home on release with no hold meter, so otherwise nothing said it left). Notices have one path (ADR 0033, <code>Screens.notify</code>): a checked JSON pill notice (toast, badge, progress, level, listen, pick, menu, cancel or clear; a question is a shell card, never a pill) as one datagram to that screen's <code>couchdogs-overlay.sock</code>, sent on its own thread without ever waiting (a full or missing daemon is one lost notice and one log line), so it can never fail or hold a join, a leave or the 1 s pass; on an install with no TV, TV notices are dropped. The first app whose window shows on a screen (Gamescope focuses it; <code>Runner.on_shown</code> from the 1 s pass, not the launch, because Steam's window came 7 s after its launch and a hint sent then ran out just as it appeared) gets the one-time hint "Hold Guide, Back or Esc for Home" ("Hold Guide for Home" on the TV, whose own pads have no Back gesture and which has no streamed keyboard) (<code>hinted</code> in settings.json, once per screen, never for a launch that only asks for room). A home also answers who watches it, <code>watchers</code>: <code>[{screen, title}]</code>, the TV first then the devices joined to that screen, by title, a test screen never; the TV's own home lists the devices joined to it. The TV's home also carries <code>controller</code> (ADR 0038 amendment): null while the host has any input paired over Bluetooth or plugged in by USB (a paired pad that is asleep counts; padd posts its counts and each screen's inputs to <code>POST /inputs</code> every change and 30 s, and counts older than 90 s are zero), else <code>{state: "looking" | "pairing" | "off", name}</code> from auto-pair, so the shell can show a dim pad with the auto-pair words and the wizard can start there. Every home also carries <code>inputs</code>: <code>[{kind, player, battery, charging}]</code> for the inputs playing on that screen now (empty when padd's report is older than 90 s), drawn left of the clock. Until the first Bluetooth read and the first count, or if no count comes within 90 s of the runner's start, the home says nothing, so a restart never flashes the panel; the field is a snapshot, so a slow BlueZ call never holds up <code>/home</code>. <code>POST /unshare {"screen": "tv"|<device>}</code> on that screen's own route (bare for the TV) ends one of them, exactly as that watcher's own Home would: the TV goes Home through the same code its Home press uses (viewer gone, pads back), a device leaves its join (<code>_drop_join</code>, the map to padd; the server's next source poll turns its stream back to its own screen), and the stopped watcher is toasted "<name> stopped sharing" while the screen that pressed it hears nothing. A watcher that already left answers that home unchanged, so a double press is harmless, and an unknown or malformed screen is 400. <code>settings.py</code> keeps the screens that turned "Others can join this screen" off as <code>no_join</code> in <code>settings.json</code> in <code>DATA_DIR/runner</code> (<code>/state</code>, beside <code>household.json</code>; <code>DATA_DIR/apps</code> is mounted at <code>/couchdogs/apps</code>, and the runner refuses to start when either mount is not a folder; rebuildable state, Docker's client state, is the <code>couchdogs-runner-cache</code> volume at <code>/cache</code>), written through a temp file and <code>os.replace</code>; a missing or junk file (non-UTF-8 bytes included) means every screen takes joins, logged once per distinct bad content, and the old <code>shared_control</code> key is ignored and kept. The household's own values live in the same file (ADR 0029): <code>group_by_kind</code> (off), <code>clock</code> (<code>"24h"</code> or <code>"12h"</code>) and <code>voice_languages</code> (up to five Whisper codes, empty for any language), and a value that is not one of those falls back to its default with one log line per distinct bad content, like a bad file. <code>hinted</code> (ADR 0033) lists the screens that already had the one-time Controls hint. A screen with joins off is left out of every <code>join</code> list and a join to it is 409; turning it off ends the joins to it (the TV goes Home if it was watching that device). A launch that needs room answers <code>needs_stop</code> with <code>stop_on</code> (<code>{app_id: "this screen" | "the TV" | <device name>}</code>) so the card can say where each app runs. A launch of an app that runs on another screen is refused with <code>RunnerBusy</code> (409 <code>busy</code>, below), and <code>own</code> starts a second copy of a <code>copies: many</code> app. On an install with no TV (ADR 0032) the same runner is still the household's (store, wizard, settings, the installer) but it has no screen: its 1 s pass returns at once, the blank-home watchdog never runs, the TV's picture is never checked, no home offers the TV to join, and one object serves every device home. Bluetooth (ADR 0038, <code>bluetooth.py</code>): the runner speaks to the host's bluetoothd over the system D-Bus socket (<code>/run/dbus</code> mounted read-only at <code>/run/host-dbus</code>; connecting to a socket is not a write) with jeepney, on its own thread every 2 s. While nothing that drives a screen (pad, remote, keyboard, other HID) is connected it keeps discovery on and pairs, trusts and connects the nearest named device in range that says it is a pad, remote or keyboard, each address at most once per 10 min (<code>BLUETOOTH_AUTOPAIR=0</code> turns that off), and toasts the TV "Paired <name>". No adapter or no bus is a plain <code>problem</code>, retried every 30 s. Its API is below</td> </tr> <tr> <td><code>padd/</code></td> <td>The pad daemon (ADR 0013, M5). Grabs every real pad (Bluetooth LE pads sit on uhid and count; uinput devices and Wolf's "Wolf ..." pads for remote clients do not), reads it with python-evdev with the pad's layout from SDL_GameControllerDB (<code>sdlmap.py</code>, ADR 0014; a pad not in it is read as xpad) and feeds one inputtino virtual Xbox pad per player into the app container in front (<code>router.py</code>; Guide goes Home through the runner). One front per screen (M6a Task 9): the runner names the front per screen, the TV's physical pads belong to screen <code>tv</code>, a remote Moonlight device's pads to that device's screen, and a pad only ever reaches its own screen's front. Remote pads come from the server's control channel: it decrypts a streaming device's Moonlight input and sends <code>arrive</code>, <code>state</code> and <code>leave</code> for one pad number as JSON datagrams on <code><PADD_SOCKET_DIR>/remote.sock</code> (padd binds it, <code>arrive</code> and <code>leave</code> meaning the pad appeared or is gone), padd turns each into a real named <code>remote:<device>:<pad></code> on that screen with Moonlight's own player number, and the buttons come from Moonlight's <code>CONTROLLER_BTN</code> flags (Guide is its <code>SPECIAL_FLAG</code>, so a remote Guide goes Home on its own screen; every pad, the TV's own included, also goes Home with Back held alone (first for a device whose Guide never arrives, a handheld on SteamOS that keeps its Steam button; the household then expected the same hold on the TV) for 1 s: no combo works there, since Moonlight makes a held Start its mouse mode and apps such as YouTube use every other button, so a lone Back is held back from the app and reaches it as a tap when let go sooner, while Back pressed with any other button goes on at once). A device with no pad at all gets the same gesture from its keyboard: the server holds a lone Escape back and sends <code>hold_start</code>, <code>hold_cancel</code> or <code>hold_home</code> for that device, and the router runs the lone Back's hold (the same pill, Home or Leave, and the device's own screen, which ends a join) with no pad and no clock of its own. Rumble goes back the other way: a remote pad's virtual pad rumbles its own device, so padd sends <code>{"op":"rumble",...}</code> to <code><PADD_SOCKET_DIR>/server.sock</code> (the server binds that one), and a socket the other side has not bound yet drops the datagram with one log line, so either side can restart alone. The directory defaults to <code>/run/couchdogs-padd</code> and is the shared <code>couchdogs-padd</code> volume in compose. The virtual pad keeps Wolf's name and ids, so emulator mappings made for Wolf keep working. Pads appear in the app the way Wolf does it (<code>hotplug.py</code>, ported from Wolf): <code>mknod</code> the node, write the udev hwdb file and send the uevent with Wolf's <code>fake-udev</code>, which padd copies into the <code>couchdogs-tools</code> volume. Unlike Wolf, padd writes the hwdb file for the <code>js</code> node too, not only the <code>event</code> node: Chromium (Electron apps such as VacuumTube) connects a pad only through its <code>js</code> node and ignores one without <code>ID_INPUT_JOYSTICK</code>. Chromium also tells pads apart only by their sysfs path up to <code>input</code>, which is <code>/sys/devices/virtual/</code> for every uinput pad, so it reads just the pad plugged last; a recipe with <code>pads: one</code> (VacuumTube) therefore gets a single pad that every pad on its screen drives, last event wins, and its rumble goes to the pad used last (ADR 0026). The runner sends it as <code>pads</code> in <code>POST /front</code> (<code>all</code> otherwise). Plugging runs on its own thread, never on a pad's reader: it is several <code>docker exec</code> calls, slow while an app starts, and a blocked reader lost whole presses (Guide included); padd logs how long each plug took, and every Guide press: the raw key down/up and any events the kernel dropped, then what the router made of it (held time and outcome: home, tap passed to the app, or already home), so a "Home did nothing" report can be matched against <code>docker logs -t</code>. Every player's pad is plugged as soon as a container comes to the front, and a newly connected pad's at once, so pads are in before the first press; such a pad starts at rest (a button held from the app left behind must not arrive pressed) and the first event still plugs a missing one. Pads die with padd, so on stop (SIGTERM) padd sends every container the "remove" for its pads, and before reusing a node name still in a container it sends that name's "remove" first: gilrs (the shell) ignores an "add" for a name whose dead pad it never saw go, which left the shell without a pad after a padd restart. A pad plugged into a shell (the TV's or a device's) gets its "add" a second time 3 s later: the kiosk's gilrs lists the pads present and only then starts its hotplug monitor on another thread, so a pad plugged while the shell starts (padd replugs within a second of a shell restart) was never seen, and gilrs ignores the repeat when the first add was seen. Sending the uevent needs <code>NET_ADMIN</code> in the receiving container, so the shell and every app get it (each in its own bridge network namespace, as Wolf does). <code>overlays/cont-init/40-couchdogs-udev.sh</code> prepares <code>/run/udev</code> in every app so libudev listens. The runner tells padd which container is in front (<code>POST /front</code>, <code>/forget</code> on port 8990) at start, on every switch and again every second, so a restarted padd routes again within a second; <code>GET /voice</code> answers <code>{"screen": ...}</code>, the screen the TV's input goes to, for the voice service; when that name now belongs to a recreated or restarted container (Docker Id or start time changed), padd forgets its old pads and plugs them in again. A device that joined the TV (M6c) has its remote pads moved to the TV's front as the lowest free TV player (the TV's own pad 1 stays 1, and a TV pad that wakes up while a guest holds its number gets it back, the guest moving to the next free one), at rest, after the device's own app got its pad released; leaving moves them back as Moonlight's own player number. Guide on such a pad still goes Home on the device's own screen, which ends the join, and rumble follows the real pad to its device. When the TV watches a device (<code>"tv": <device></code> in the map, M6c step 2) the TV's pads go to that device's front the same way, as guests after its own players, and Guide on them goes Home on the TV; a device joined to the TV then plays on the watched device too (one level; the runner refuses cycles, and padd drops a map that has one). padd never plugs a pad into the viewer container itself. Only the TV and device screens are accepted on either side of a map entry, and a cycle between the TV and a device is dropped; a device that joined another device stays there rather than following it to the TV. With no TV (<code>TV=off</code>, ADR 0032) a pad plugged into the host is left alone and logged once per node ("no TV: host pad <name> ignored"): its pads belong to screen <code>tv</code>, which does not exist; a remote device's pads come from the server and are unaffected.. Keyboards, mice and remotes on the host's USB or Bluetooth (<code>peripherals.py</code>, ADR 0038) are grabbed too and sent to the TV's <code>couchdogs-input</code> socket, or to the device screen the TV shows, with the server's lone-Escape hold; their volume keys go to the runner's <code>POST /volume</code> instead, which moves the TV screen's default sink with <code>pactl</code> and shows a <code>level</code> notice in the TV's pill; a VM's console devices and the machine's own PS/2 keyboard are left alone; a remote's number pad types multi-tap letters while an app is in front, the letter being chosen shown as a <code>pick</code> notice in the TV's pill; a remote's mic key (<code>KEY_VOICECOMMAND</code>) never reaches the app: padd posts it with the node's Bluetooth address to the voice service's <code>POST /press</code>, which opens that remote's mic (the BPR3S sends no ATVV START_SEARCH, only this key); when the service is down or has no ATVV remote with that address, padd's TV pill says "Voice isn't available". padd also posts how many pads and host input nodes it holds and which inputs play on each screen, with battery where known (<code>POST /inputs</code>, every change and 30 s; host pads from the kernel's <code>power_supply</code>, a device's pads from the server's <code>battery</code> op), so every home can show its inputs and the TV's can say when none can drive it.</td> </tr> <tr> <td><code>voice/</code></td> <td>Voice typing (ADR 0042): a remote's mic button (Google's ATVV over Bluetooth LE) becomes text in the app in front. <code>bluez.py</code> talks to the host's bluetoothd over the system D-Bus socket (<code>/run/dbus</code> mounted read-only at <code>/run/host-dbus</code>, jeepney), finds connected devices whose GATT service is the ATVV one, subscribes to its audio and control characteristics, writes GET_CAPS on TX once per connection, and feeds the bytes to <code>atvv.py</code>; <code>adpcm.py</code> decodes IMA ADPCM and <code>endpoint.py</code> ends the take on 1.2 s of silence after speech, a second press, the remote's stop or 10 s. <code>stt.py</code> drops the take's rumble below 100 Hz and, with faster-whisper's own voice activity filter, its parts without speech (a silent take otherwise came back as "thank you"), then transcribes it on the CPU with the baked-in faster-whisper <code>base</code> model in the household's languages, and <code>voice.py</code> types the cleaned words through the runner's <code>POST /type</code> into where padd says the remote's keys go, with the TV's pill showing "Listening…", "Writing…", the words, or why nothing was typed. It runs as its own <code>voice</code> container from the padd image (1 GB, <code>python /app/voice.py</code>), one session at a time across all remotes, and each time an ATVV remote becomes ready it tells the runner (<code>POST /voice</code>); it serves on 8995 <code>GET /health {ready}</code> and <code>POST /press {address}</code> (padd's mic key; 200 <code>taken</code>, 404 when no ready ATVV remote has that address). The mic opens on that press or on the remote's own START_SEARCH; a second one from the same remote within 0.5 s is the same press. Audio and words are never logged or written to disk: a take logs only its length and outcome.</td> </tr> <tr> <td><code>server/</code></td> <td>Our own Moonlight server (ADR 0012, M6a): C++ built on Wolf's MIT protocol library vendored in <code>third_party/wolf/</code> (its <code>ORIGIN</code> has the commit, the copied paths and what we changed; <code>compat/</code> is the one logger interface Wolf's RTSP parser needs), packaged by compose's <code>server-image</code> service (a clone) into <code>couchdogs-server:local</code>, which an install pulls from ghcr.io. Its <code>Dockerfile</code> has <code>build</code>, <code>test</code> and <code>runtime</code> (Debian trixie, pinned by digest) stages; <code>test.sh</code> builds the <code>test</code> stage with the capped buildx builder and runs ctest there. Its state directory holds <code>cert.pem</code>, <code>key.pem</code> (0600), <code>uniqueid</code>, <code>hostname</code> and <code>clients.json</code>; <code>import_wolf.py</code> seeds it once from Wolf's <code>config.toml</code> and <code>cert.pem</code> (Wolf's default name "Wolf" becomes "Couchdogs", a name the owner chose is kept), so already-paired devices need no new PIN. <code>src/http.{hpp,cpp}</code> serves the Moonlight endpoints on <code>BASE_PORT</code> (plain: serverinfo before pairing, pairing, the PIN) and <code>BASE_PORT - 5</code> (TLS: serverinfo, applist with the single app <code>Couchdogs</code>, launch, resume, cancel, the app icon), accepting a device only when its certificate is one in <code>clients.json</code>; <code>POST /pin</code> answers only on the loopback address (with an <code>id</code> when several devices wait). Every waiting pairing has a random 8-hex id and a name from the device's reverse DNS (else <code>Device at <address></code>, since every Moonlight client sends the same uniqueid); the PIN card's "What is it?" pick replaces that name (any text: control characters and Unicode format characters dropped, cut to 32 bytes, numbered " 2", " 3" when another device has it, ADR 0029), and <code>src/pair_socket.{hpp,cpp}</code> serves the list, takes a PIN for an id on a Unix socket, and (ADR 0029) lists the paired devices (<code>devices</code>), renames one (<code>rename {id, name}</code>: the five kinds are what a home offers, any text is taken, cleaned and made unique as at pairing) and forgets one (<code>forget {id}</code>: it leaves <code>clients.json</code>, a stream already running is not cut, and the device must pair again), all on a Unix socket in the <code>couchdogs-pair</code> volume, mounted in the server, <code>web</code> and every home's shell (M6b; device shells too, so any home types the PIN without the network (<code>pair_cli.py</code>, baked into the image, is the same client for a host without a TV: <code>./couchdogs pair</code> runs it in the server container, <code>--name</code> gives a device its name where the TV's card would ask, and <code>devices</code>, <code>rename ID NAME</code> and <code>forget ID [--yes]</code> list, rename and forget paired devices, the same socket commands every home's Settings page uses, ADR 0029)), a request with no PIN after 2 minutes is answered (and logged) within a second of that, so the device fails on time instead of on its next tap, and the app's picture is 3:4 box art (the dogs with the word under them, <code>stack/server/brand/</code>) baked into the binary at build time: Moonlight stretches every picture to 3:4 and caches it by app id for good, so the single app's id is 2 since the art changed. Launch, resume and cancel go through <code>Sessions</code> (Task 8), so nothing here starts a screen. <code>src/rtsp.{hpp,cpp}</code> serves RTSP on <code>BASE_PORT + 21</code> and matches every request to its device by the connecting client's address, never by anything the request names; SETUP advertises video <code>BASE_PORT + 111</code>, audio <code>+211</code> and control <code>+10</code> and hands the client its launch's 16-byte ping payload (video and audio) and ENet connect data (control), so the stream layer can recognise the device by more than its address, and ANNOUNCE becomes one <code>StreamConfig</code> (codec, size, fps, bitrate, FEC, colour, audio) for that device, refusing AV1. <code>src/packetizer.{hpp,cpp}</code> splits an encoded frame (or an Opus packet) into the RTP packets, Reed-Solomon FEC and AES-encrypted audio a Moonlight client expects, keeping Wolf's bytes without its GStreamer elements, so the stream layer (Tasks 7 and 8) only has to encode and write to the socket. <code>src/capture.{hpp,cpp}</code> reads that screen's Gamescope node and its default sink's monitor straight from the screen's own PipeWire daemon (by socket path, with <code>pw_stream</code> and the session manager's autoconnect; BGRx or BGRA in system memory, one copy per frame, no bigger than the stream: the capture sets Gamescope's own <code>requested_size</code> format key to the stream's size, so Gamescope shrinks a bigger screen on its GPU, keeping the aspect, and a 1080p device watching a 4K TV copies a quarter of the bytes (4K frames held such a stream at 44 fps on the host), with Gamescope's per-buffer scale keeping the drawn pointer's relative moves in the screen's pixels; and S16 monitor audio at 48 kHz in a bounded ring that drops the oldest rather than growing), and <code>src/pacer.{hpp,cpp}</code> hands the encoder one frame per tick at the client's fps on a fixed grid, repeating the last frame while the screen sends none (Gamescope sends on change, so a static home screen would otherwise hit the client's 7 s timeout); a cancelled pacer stops within 5 ms, which is how a stream ends. <code>src/encoder.{hpp,cpp}</code> turns one paced frame into one HEVC or H.264 access unit and 5 ms of PCM into one Opus packet: the video goes through a libavfilter graph (<code>hwupload,scale_vaapi=format=nv12</code> plus the client's colour matrix, range, primaries and transfer, so the colour conversion and any scaling happen on the GPU and the pixels match the VUI) into the VAAPI encoder (VBR peaking at the negotiated bitrate with a one-frame VBV, ADR 0017; no B-frames, an IDR only on request, parameter sets in band; when the first SPS shows a bigger picture than the client asked for, as Mesa 25.0's HEVC encoder on some AMD GPUs writes 1920x1088 with no crop, libavcodec's <code>hevc_metadata</code> filter writes the crop into every SPS so the client shows exactly its size; the driver's filler units, which that filter cannot read, are dropped first, and a unit it still refuses streams on uncropped) and the audio through libavcodec's libopus (48 kHz S16, CBR, the channel bitrate from Wolf's table), with every encoder option coming from one pure function a test can inspect without a GPU. The video encoder runs in a child process (<code>src/encode_process.{hpp,cpp}</code>, the same binary's <code>encode-helper</code> command, frames over a socket pair; ADR 0016), because Mesa aborts any process whose VAAPI context sees a GPU reset: the stream kills a helper that died, hung for 2 s or failed, builds a new one a second later and starts it with an IDR, and gives up after ten failures in a row. A capture whose screen went away (Gamescope ends on a GPU reset) makes the stream ask the runner for that screen again and reconnect, repeating the last picture meanwhile, for up to 60 s. <code>src/session_manager.{hpp,cpp}</code> joins those pieces (Task 8): a launch asks the runner (<code>src/runner_client.{hpp,cpp}</code>, Task 10's <code>/screens</code> API) for the device's screen, sending the paired device's name for the TV's join tile (left out when it has none) and generates the launch's 16-byte ping payload (printable, it travels in an RTSP header) and its ENet connect data, ANNOUNCE builds that device's <code>src/stream.{hpp,cpp}</code>, and the client's UDP pings on the shared video and audio sockets (<code>BASE_PORT + 111</code> and <code>+211</code>) start it: the first ping on a channel decides where it sends, and video starts with an IDR. A launch is serialised per device only, so one device's cold start (up to 30 s in the runner) never holds up another device's launch. A relaunch for a device ends its old stream before a new one can send and keeps the screen open (the runner reuses it), while cancel waits for a launch of that device that is still starting, then stops the stream and releases the screen. A device that disconnects without quitting (the usual way a phone or handheld leaves) releases its screen too, once, and keeps its launch so a quick <code>/resume</code> gets the same screen back; release starts the runner's idle timer. Serverinfo calls a device busy (Couchdogs running) while it has a launch, left or streaming, until <code>/cancel</code>: Moonlight's Quit only ends when a poll sees the app stop, so a device that read "not running" the moment it left stayed on "Quitting" for good. The server owns screen lifetime in the other direction as well: while a device's stream runs it asks the runner for that screen again every five minutes (<code>Settings::screen_keepalive</code>), which clears the runner's idle deadline, so a runner restart can no longer idle-stop a screen somebody is playing on after thirty minutes. That call runs on the session layer's own screen worker thread, like the release a disconnect queues, so neither blocks the control channel's single ENet thread. The same thread asks the runner once a second which screen each running stream shows (<code>Settings::source_poll</code>, <code>GET /screens/<device>/source</code>, 2 s timeout): when the device joined another screen (M6c) the stream swaps its captures to that screen's PipeWire socket (the TV's <code>/run/couchdogs-tv/pipewire-0</code>, or <code><device>/run/pipewire-0</code> on the <code>couchdogs-screens</code> volume), the next frame is an IDR and a new size rebuilds the encoder; the device's own captures stay connected (parked) while it shows another screen and are reused on the way back, because closing them crashed the device's Gamescope twice in four joins on 2026-11-20; a 404 (a runner that lost the screen) means the device's own screen, and a runner that errors leaves the stream as it is, logged once per streak. A recovery after a swap reconnects to the swapped screen. A stream that shows another screen marks its own picture (<code>src/marker.{hpp,cpp}</code>, ADR 0033): the server decodes the one pill's art baked from <code>stack/server/brand/</code> (generated by <code>stack/images/screen/pill.py</code>, see its README) and blends it into a copy of each frame, in the shell's logo block (the ring centred left of the dog mark, words in the block's own shape). Joined to the TV it says "On the TV" for three seconds, joined to another screen "On another screen"; the words fade into the join ring alone in their last 320 ms (8 steps, each one more marked copy, so a still picture is not re-marked every frame), and the ring, a small 48 px ring, fades down to about 40% of its opacity ten seconds after it appears and stays dim while the device watches (a hold shows it at full opacity, and a hold's cancel starts the ten seconds again; the steps mean a still picture is re-marked a few times, not per frame). The joined screen toasts "<device> joined" (the TV joining a device toasts "The TV joined" there), and the joiner never reads it: a screen's notices stay out of the picture it shares (ADR 0036). A hold the device's own pads told padd about grows that ring into "Leave" with a meter, from 30 baked frames picked by the hold's elapsed time (<code>padd</code> sends one start and one cancel on its server.sock, so the stream animates it locally). Only that device's stream is marked: nothing is ever drawn on the TV's screen itself (not on Gamescope, not in the shell's picture), and a stream on its own screen passes its captured frames through untouched. A frame's packets go out in Wolf's paced batches (at most 16 per batch, 80% of a gigabit) rather than one burst, and a refused send is logged once per stream. The HTTP and HTTPS servers each run their io loop on several threads, because a launch handler sits in the runner for up to 35 s: on one thread every other device's serverinfo poll would show the host offline meanwhile. <code>serve</code> reads <code>BASE_PORT</code> (47989), <code>STATE_DIR</code>, <code>RUNNER_URL</code>, <code>RENDER_NODE</code> and <code>GPU_VENDOR</code> from the environment, starts the HTTP(S), RTSP and stream layers, and on SIGTERM stops every stream without stopping a screen, so a server restart leaves the screens and the apps in them running; a handler still waiting on the runner is given 2 s at shutdown and then left to the exit, which keeps a clean exit 0 inside Docker's 10 s, and the control channel starts beside it. <code>src/control.{hpp,cpp}</code> serves Moonlight's control channel on <code>BASE_PORT + 10</code> over ENet (the <code>cgutman/enet</code> fork Wolf pins, at the same commit): a client connects with the 16 bytes SETUP gave it and is matched on nothing else, so an unrecognised connect is disconnected at once and the connect data is never logged, and the launch's key decrypts everything it sends (Moonlight's v2 AES-GCM control stream). Controller arrival and multi packets become the arrive/state/leave datagrams padd takes (<code>src/padd_client.{hpp,cpp}</code>, on the shared <code>couchdogs-padd</code> volume: padd binds <code>remote.sock</code>, the server binds <code>server.sock</code>), a MULTI whose active-gamepad mask drops a pad's bit leaves it, an IDR request reaches that device's stream, and the client's TERMINATION stops the stream and releases the screen like a disconnect does. Mouse, scroll, keyboard, UTF-8 text and touch become JSON datagrams for <code>couchdogs-input</code> on the screen the device is watching (<code>src/input_client.{hpp,cpp}</code>, ADR 0028): the daemon's <code>input.sock</code> sits beside that screen's PipeWire socket, so a device that joined the TV drives the TV's apps and leaves its own screen behind; on a join, a disconnect or a launch end the old screen is told to let go of that device's every button and key. Every datagram names its device, so two devices on one screen (a handheld and a phone joined to the TV) each keep their own gesture and held keys, and a release lets go of one device's. A lone Escape held for 1 s on a device's keyboard is its Home, exactly as a lone Back held on its pad is (ADR 0033, amended): one hold per peer in <code>src/key_hold.{hpp,cpp}</code>, timed by the service loop, holds the key back from the app, lets a release before the second through as a tap 50 ms later, sends Escape on at once (then that key) when another key arrives while it is down, swallows the release after Home, and tells padd one <code>hold_start</code>, <code>hold_cancel</code> or <code>hold_home</code> through <code>src/padd_client.{hpp,cpp}</code> so the pill, the Leave and the Home stay padd's. A button, a key, text or a finger going down, up or cancelled is retried for up to 20 ms when the daemon's queue is full, within 50 ms of retry sleep per second for the whole channel; a move is not. Coordinates are the client's fraction of its window, clamped; text takes the length the packet carries (Moonlight sends only the bytes it has) and goes in as a JSON string that is never logged. A touch hover is ignored: Moonlight repeats it while a pen moves above the screen, and placing a finger there would drag and then click. Pen, controller touch, motion and battery are dropped with one log line per kind per session. When a launch ends (relaunch, cancel, stop_all) its peer gets Moonlight's termination packet and then a disconnect, and padd releases every pad that device had; a disconnect or timeout does the same, so a device that leaves mid-press cannot leave a button held. Rumble from padd travels back to that device encrypted, and a peer is only written to from the channel's own thread. With <code>GPU_VENDOR=nvidia</code> (ADR 0023) the same settings function builds <code>hevc_nvenc</code> / <code>h264_nvenc</code> options instead (preset p1, tune ull, VBR, <code>forced-idr</code>) and a CPU filter, libswscale <code>scale</code> with the client's matrix and range and <code>format=nv12</code>, because NVENC takes NV12 from system memory and Debian's FFmpeg has no CUDA scaler; no VAAPI device is opened, the constructor only checks that this libavcodec has the NVENC encoder, and the backend travels to the helper in its own hello field. <code>selftest-encode</code> runs synthetic frames through the real encoder on a machine with a GPU and prints the frame rate it measured (optionally from a bigger source size), and <code>selftest-capture</code> captures a screen's Gamescope node at a stream size and prints the frame sizes and scale it got. Compose runs it as service <code>server</code> (ADR 0012) with the image <code>couchdogs-server:local</code>, <code>network_mode: host</code> (Moonlight clients look for the host's address), 512m, the render node, a former Wolf install's <code>cfg/</code> (<code>WOLF_DIR</code>) read-only at <code>/wolf-cfg</code> (absent on a new install), its own state in the plain folder <code>DATA_DIR/server</code> (a bind, not a volume, so a backup of <code>DATA_DIR</code> keeps every pairing; <code>entry.sh</code> exits with "run ./couchdogs setup" when it is missing and makes it 0700) and <code>BASE_PORT</code> from <code>SERVER_BASE_PORT</code> (47989), and <code>entry.sh</code> runs <code>import_wolf.py</code> once before the server starts. A launch flows server -> runner <code>POST /screens</code> (the runner's internal API on the host's loopback, <code>RUNNER_HOST_PORT</code>, 8980) -> that screen's PipeWire capture, and the client's input comes back as pad datagrams on the <code>couchdogs-padd</code> volume</td> </tr> <tr> <td><code>../couchdogs setup</code></td> <td>Detects the TV's GPU, render node, HDMI sound card and resolution from <code>/sys</code>; asks two folders (<code>DATA_DIR</code>, <code>LIBRARY_DIR</code>), writes <code>.env</code> beside <code>compose.yml</code> (an install folder's, or a clone's <code>stack/.env</code>) with absolute paths, creates the data folders, and writes <code>GPU_VENDOR</code> (amd, intel, nvidia or other, from the card's PCI vendor id, detected every time); for NVIDIA it also writes <code>COMPOSE_FILE=compose.yml:compose.nvidia.yml</code> and says on stderr when <code>nvidia-drm.modeset</code> is not <code>Y</code> and that Docker needs the NVIDIA Container Toolkit (setup cannot check the toolkit). It also writes <code>TV=on</code> with a connected output, or, with none, says "No TV found", asks "Set up without a TV? [Y/n]" (yes under <code>ASSUME_YES</code>), writes <code>TV=off</code>, adds <code>compose.no-tv.yml</code> to <code>COMPOSE_FILE</code> (dropped again when a TV is found) and picks the GPU by its render node, since device screens and the encoder need a GPU but not a TV; the TV's own keys keep their values or defaults so turning a TV on later is setup again (ADR 0032). For a TV above 1080p with no <code>TV_RESOLUTION</code> yet, it runs the server image's encode selftest at the TV's mode once and writes that mode at 55 fps or more, else 1920x1080 (ADR 0034; not under <code>DRY=1</code>). A rewrite keeps the folders and choices from the old <code>.env</code> (only the settings <code>.env.example</code> lists)</td> </tr> </tbody> </table> <h3 id="runner-api">Runner API</h3> <p>Internal, for the shell, padd and the server (port 8980, no token; published on the host's loopback only, because the server runs on the host network): <code>GET /bluetooth</code> (<code>{available, problem, scanning, devices: [{address, name, kind, paired, connected, state}]}</code>: paired devices and the near, named pads, remotes and keyboards; <code>state</code> is "pairing" or why the last try failed), <code>POST /bluetooth {op: scan | pair | forget, address}</code> (scan looks for a minute; pair runs in the background; 400 for a bad or already paired address, 409 when BlueZ refuses to forget; a forgotten device is not auto-paired back for 10 min), <code>GET /home</code> (apps for the page: each with <code>kind</code> (the recipe's store kind, or null), <code>running</code>, <code>paused</code> (frozen by the runner, ADR 0037), <code>front</code> (the runner put it in front) and <code>shown</code> (also focused by Gamescope, as of the last 1 s pass: its window is really on screen)), <code>POST /home</code> (shell in front), <code>POST /notify {op, text, seconds}</code> (one status pill notice on the TV's screen, ADR 0033; <code>{}</code> with <code>shown</code> false when its drawer is not there, and never a 4xx), <code>POST /volume {change}</code> (<code>up</code>, <code>down</code> or <code>mute</code>: the TV screen's default sink by <code>pactl</code>, 5% a step up to 100%, shown as a <code>level</code> notice in the TV's pill; answers <code>{volume, muted}</code>, 503 when the TV's sound cannot be read, ADR 0038), <code>POST /launch {app_id, confirm_stop?}</code> (answers <code>started</code>, <code>front</code>, or <code>needs_stop</code> with the apps that would have to stop for memory) (<code>own: true</code> starts a second copy of a <code>copies: many</code> app; an app that runs on another screen is 409 <code>{error, busy: {screen, title, join, own}}</code>, <code>join</code> true when that screen can be joined (the TV or a device with a picture, never a test screen), <code>own</code> true only for <code>copies: many</code>), <code>POST /stop {app_id}</code>. <code>GET /voice</code> answers <code>{languages: [...]}</code>, the household's Whisper codes in the order its page keeps them, empty for any language (remote voice typing); <code>POST /voice {}</code> is the voice service saying a remote with a mic is ready, kept as <code>voice_remote</code> so Settings shows Voice search from then on. On the TV, <code>home</code> also has <code>join</code> (<code>[{screen, title, front_title, away_minutes}]</code>, device screens with a picture), <code>joined</code> (the watched device or null) and <code>watchers</code> (<code>[{screen, title}]</code>, the devices joined to the TV), and <code>POST /join {"screen":"<device>"}</code> shows that screen on the TV and answers the TV's home (404 no such screen, 409 no picture or a cycle); <code>POST /unshare {"screen":"<device>"}</code> stops that device watching the TV (the TV goes Home, the device is toasted) and answers the TV's home; <code>POST /home</code> ends it. Every <code>join</code> entry also has <code>front_title</code> (the title of the app in front on that screen, or null) and <code>away_minutes</code> (null while that device is connected, else the whole minutes since it was released, or always null for the TV). Every <code>home</code> also carries <code>settings</code> (<code>{group_by_kind, clock, voice_languages, voice_remote}</code>, the household's values, ADR 0029), and the TV's carries <code>about</code> (<code>{version, web: {port, address}}</code>, read only: a release's number (<code>org.opencontainers.image.version</code>, e.g. <code>1.2.0</code>), else the commit the runner image was built from (<code>org.opencontainers.image.revision</code>, 7 characters; the image README's build command and <code>compose.build.yml</code> with <code>COUCHDOGS_REVISION</code> set it), else <code>IMAGE_TAG</code>, else "unknown"; <code>WEB_URL</code> when set, else <code>http://</code> and the <code>HOST_ADDRESS</code> setup found, else no address; and the <code>WEB_PORT</code>). The TV's <code>home</code> and a device's also carry <code>joinable</code> (whether others may join that screen, ADR 0027), and only the TV's carries <code>"tv": true</code> (the page leaves out its "This device" row there). <code>POST /settings</code> (the TV's route is bare, a device's is <code>/screens/<device>/settings</code>) takes <code>{"joinable": true|false}</code> for that screen, and <code>{"group_by_kind": true|false}</code>, <code>{"clock": "24h"|"12h"}</code> and <code>{"voice_languages": ["en", "pt"]}</code> (up to five Whisper codes, for the voice service) for the household, which any home may set; 400 for anything else, 503 when the file cannot be written. It answers that screen's home. A remote device's screen is its own: <code>POST /screens {device,width,height,fps,name?,test?}</code> (<code>name</code> optional, cleaned, anything not a string ignored; <code>test</code> true opens a screen the join lists never show and nothing may join, any other value is no) answers <code>{"screen","pipewire"}</code> once its PipeWire socket and Gamescope node exist (up to 30 s, then 503 with the screen left running for a retry), <code>POST /screens/<device>/release</code> stops it after <code>SCREEN_IDLE_MINUTES</code> unused, and <code>/screens/<device>/home|launch|stop</code> are the calls above on that screen; the bare paths are the TV's. An install with no TV (ADR 0032) answers the bare TV paths with 404 <code>this install has no TV</code> (no TV shell is running to ask) and does not start the control API below, whose every route restarts, homes or stops the TV's screen; every device's own paths work as before. A device's <code>home</code> also has <code>join</code> (<code>[{screen, title, front_title, away_minutes}]</code>: "tv" first, titled "The TV", then the other device screens with a picture, never its own, empty while nothing is there to join), <code>joined</code> (<code>"tv"</code>, another device, or null) and <code>watchers</code> (<code>[{screen, title}]</code>: the TV while it shows this screen, then the devices joined to it, by title, a test screen never); <code>POST /screens/<device>/join {"screen":"tv"|<device>}</code> joins (a screen that is not there or is its own is 400, a TV with no picture 409 <code>the TV is not on</code>, a device screen with none 409) and answers that home, and <code>POST /screens/<device>/notify</code> is the same notice on that screen's pill, <code>POST /screens/<device>/unshare {"screen":"tv"|<device>}</code> stops that watcher watching this screen (M6c; a watcher that already left changes nothing, an unknown or malformed one is 400) and answers that home, and <code>GET /screens/<device>/source</code> answers <code>{"screen","pipewire"}</code>, the screen its stream shows: <code>tv</code> and the TV's socket, or the joined device and its socket on the screens volume (404 for a device with no open screen). Store (M7a, ADR 0020; the same paths under <code>/screens/<device>/</code> act the same, it is the household's store): <code>GET /store</code> (every recipe with a <code>store</code> block, Watch then Play, each with <code>state</code> <code>install</code>, <code>installed</code>, <code>update</code>, <code>waiting</code>, <code>installing</code> or <code>failed</code>, <code>progress</code>, the last 30 log lines on failure, <code>uses</code> (plain lines from the recipe: the household folders it mounts, the devices it gets, any loosened sandbox with the recipe's <code>why</code>), an <code>icon</code> URL, and <code>size</code> in bytes: Docker's size of the image once it is here (<code>measured: true</code>, noted from the inspect the state already does), the recipe's estimate before (<code>measured: false</code>; the disk check always uses the estimate); a build folder the index carried is missing, or a pull has no index source, is <code>failed</code> with that reason and the home's <code>errors</code> names it too; the response also carries <code>store_error</code>: <code>Store signature check failed</code>, <code>Store needs a token: run ./couchdogs store-token on the host</code> (a private store refused an anonymous fetch; the public store needs no token), <code>Store not reachable, showing the last list</code> (cosign could not reach the registry too), <code>Store not set up</code> (no <code>STORE_INDEX</code>) or null), <code>GET /store/icon/<id></code> (that app's icon from the verified cache, type from its extension; 404 for an id the index does not list, and nothing from the request becomes a path), <code>POST /store/install {app_id}</code> (202, queued; a pull needs the size plus 5 GB free, a build twice the size plus 5 GB), <code>POST /store/remove {app_id}</code> (removes the image only; 409 while the app runs on any screen or installs, and a missing image is already removed). Home lists only installed apps (image present). Control, for Home Assistant (port 8960 inside, published on <code>TV_CONTROL_PORT</code>, only when <code>TV_CONTROL_TOKEN</code> has at least 16 characters, <code>Authorization: Bearer <token></code>): <code>GET /status</code>, <code>POST /restart</code> (restarts <code>screen-tv</code>), <code>POST /home</code>, <code>POST /stop-front</code>. It took over the old TV supervisor's control (ADR 0006); the URL and token stayed the same.</p> <h3 id="install-folder-and-state">Install folder and state</h3> <p>An install is a folder with <code>compose.yml</code>, <code>.env</code>, <code>couchdogs</code>, <code>data/</code> and <code>library/</code> (ADR 0024; layout and moving folders in the <a href="../install/#install-folder">install guide</a>). Images are pulled from ghcr.io, published by <code>.github/workflows/images.yml</code> on <code>v*</code> tags; a clone builds them with <code>compose.build.yml</code>. All state is plain folders under <code>DATA_DIR</code> and is bind-mounted:</p> <table> <thead> <tr> <th>State</th> <th>Where</th> <th>Notes</th> </tr> </thead> <tbody> <tr> <td>App settings and saves</td> <td><code>DATA_DIR/apps/<app id></code></td> <td>Created by the runner, owned by uid 1000; the folder name is the app id (recipes have no <code>home:</code>)</td> </tr> <tr> <td>Pairing</td> <td><code>DATA_DIR/server</code></td> <td>Certificate, key, paired devices; mode 0700; <code>entry.sh</code> stops with a message when the folder is missing</td> </tr> <tr> <td>The sign-in code's key, household settings, the store</td> <td><code>DATA_DIR/runner</code></td> <td><code>household.json</code>, <code>settings.json</code> (the screens closed to joins, grouping, the clock, the voice languages, whether a mic remote was ever ready); <code>store/</code> (the last verified index and its icons and build folders), <code>store-serial</code> (the newest serial accepted) and <code>store-token</code> (0600, only for a private store; ADR 0030)</td> </tr> <tr> <td>Rebuildable cache</td> <td>volume <code>couchdogs-runner-cache</code></td> <td>Docker's client config and the store's base-image layout; not data</td> </tr> <tr> <td>ROMs, BIOS, media, games</td> <td><code>LIBRARY_DIR/<name></code> or <code>ROMS_DIR</code>, <code>BIOS_DIR</code>, <code>MEDIA_DIR</code>, <code>GAMES_DIR</code></td> <td>Read-only where the app does not write them; a symlinked per-system folder inside <code>roms</code> is mounted by its target. Apps get them as <code>HostConfig.Mounts</code> binds, which Docker refuses for a missing source (a <code>Binds</code> string would create it, root-owned, inside the library). The runner sees <code>LIBRARY_DIR</code> read-only at <code>/library</code> and always lists ROMs through <code>/roms</code> (<code>ROMS_DIR</code>, else <code>LIBRARY_DIR/roms</code>, so Docker follows a host symlink there; unset, an empty <code>./library-none</code>) and checks a folder exists first: a missing optional one is left out with a log line, a missing required one fails the launch naming its setting. An override it cannot see, or a system link outside the library, goes to Docker; a refusal drops that one system or optional folder and creates the app again, and a refused required folder names its setting</td> </tr> </tbody> </table> <p>Runtime sockets stay volumes (<code>tv-x11</code>, <code>tv-run</code>, <code>screens</code>, <code>padd-sock</code>, <code>pair-sock</code>, <code>tools</code>). Files once mounted from the repo (hooks, entry scripts, recipes, the shell's code) are baked into the images (<code>stack/images/...</code>, <code>stack/runner/Dockerfile</code>).</p> <p>Things that are easy to get wrong:</p> <ul> <li><strong>Why a start hook for app fixes.</strong> Mounting our config files read-only would stop the app saving its own settings (Dolphin writes its config on exit), and derived images would need rebuilding on every upstream release. The hook runs before the app starts, so it never races the app's own writes, and it sets only our keys.</li> <li><strong>Restarting one TV service.</strong> Name it (<code>docker compose restart screen-tv</code>): a plain <code>docker compose stop</code> or <code>restart</code> also stops the server, which drops every remote device mid-game.</li> <li><strong>Moving from Wolf.</strong> Two copies, neither merges or deletes. <code>WOLF_DIR</code> (Wolf's data folder, optional): the server imports the cert, key and pairings from its <code>cfg/</code> once on its first start, so paired devices need no new PIN. <code>./couchdogs import-wolf <dir></code> (dry run unless <code>DRY=0</code>, refuses while an app runs) copies Wolf UI's <code>user</code> profile folders <code>WolfES-DE</code> and <code>WolfSteam</code> to <code>DATA_DIR/apps/es-de</code> and <code>steam</code> through a staging folder <code>apps/.<id>.importing</code>, skips a target that has files (one holding only empty folders is removed with <code>rmdir</code> first, which never deletes a file), leaves out WolfSteam's <code>.local/share/Steam/steamapps</code> (installed games; it names that folder on the host, <code>WOLF_HOST_DIR</code>, for <code>GAMES_DIR</code>) and crash dumps (<code>core</code>, <code>core.<pid></code>) at a profile's top, skips sockets and pipes, prints each step as it finishes, and lists other profiles as not copied. Both steps belong before the first <code>docker compose up</code>; a pairing skipped because <code>server/</code> has state prints how to redo it (stop the server, move <code>server/</code> aside by hand, run again). Update with <code>docker compose pull && docker compose up -d --remove-orphans</code>, which removes the old <code>wolf</code> and <code>wolf-config</code> containers.</li> </ul> <h2 id="components-we-own">Components we own</h2> <ol> <li><strong>Shell</strong>: the controller-driven home screen, the Store, the Join page, Settings, the first-run wizard and the PIN card, shown by our Servo kiosk (ADR 0010, <code>stack/shell/</code>). Settings has a Bluetooth card (ADR 0038): pads, remotes and keyboards in pairing mode show there and pair with A, paired ones are forgotten after a confirm, through the runner's <code>/bluetooth</code>. The header shows each input on that screen (glyph, player, battery bars); with no controller the TV's home shows a dim pad and the auto-pair words there, and the wizard opens on the same words.</li> <li><strong>Store</strong>: the catalogue lives in the signed companion repo and the runner installs from it, verified (ADR 0030); Couchdogs carries no app recipes.</li> <li><strong>Unbreakable TV</strong>: Gamescope, the shell, the runner and padd restart by themselves (<code>restart: unless-stopped</code>); the runner brings the shell back when the app in front exits and serves the Home Assistant control (ADR 0013). When a screen restart took the app in front away (a GPU reset ends Gamescope and every app on it), the runner opens that app again at its own start, once per app per 10 minutes (ADR 0016). A TV home that Gamescope leaves unfocused (HDMI then stays off) for 30 s gets the TV screen restarted (a kiosk restart did not help when it happened), at most three times per 10 minutes, then it waits (the kiosk-only second try it had before left a TV blank for over a minute after two picture size changes in a row); each try logs the windows Gamescope sees.</li> <li><strong>App config overlays</strong>: per-app defaults (Dolphin, pad mappings), applied by a start hook before the app starts because these apps rewrite their config on exit. They live in the store repo's app image folders (ADR 0030).</li> <li><strong>Host profile</strong>: memory limits (in the stack), OOM policy and VM startup (documented in <code>docs/host-setup.md</code>, not applied).</li> </ol> <h2 id="known-constraints">Known constraints</h2> <ul> <li>One GPU wired to the TV (or, with no TV, one GPU for the device screens and the encoder; ADR 0032), shared with other services on the host. AMD and Intel work through VAAPI; NVIDIA through the NVIDIA Container Toolkit and NVENC (ADR 0023, not yet run on NVIDIA hardware). Details of the owner's host are in <code>AGENTS.local.md</code>.</li> <li>padd needs <code>/dev/input</code> and <code>/dev/uinput</code>, screens and apps the GPU's <code>/dev/dri</code> nodes (and, on NVIDIA, the toolkit's GPU request); controllers connect over Bluetooth to the host.</li> <li>Every container gets a memory cap: the host is shared, and Wolf's runaway-memory path on resume taught us that one stream can eat the machine.</li> </ul> </article> </div> <script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script> </div> <button type="button" class="md-top md-icon" data-md-component="top" hidden> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M13 20h-2V8l-5.5 5.5-1.42-1.42L12 4.16l7.92 7.92-1.42 1.42L13 8z"/></svg> Back to top </button> </main> <footer class="md-footer"> <div class="md-footer-meta md-typeset"> <div class="md-footer-meta__inner md-grid"> <div class="md-copyright"> Made with <a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener"> Material for MkDocs </a> </div> </div> </div> </footer> </div> <div class="md-dialog" data-md-component="dialog"> <div class="md-dialog__inner md-typeset"></div> </div> <script id="__config" type="application/json">{"annotate": null, "base": "..", "features": ["navigation.sections", "navigation.top", "search.suggest", "content.code.copy"], "search": "../assets/javascripts/workers/search.a7633da7.min.js", "tags": null, "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version": "Select version"}, "version": null}</script> <script src="../assets/javascripts/bundle.a5f9d56c.min.js"></script> </body> </html>