Commit Graph

3 Commits

Author SHA1 Message Date
Denis Defolie c6523ac213 Media tab: several players per file type, chosen by long press
Each type (sound, image, video) can now have 1 to 8 named players on
/admin, reordered with the arrows; the first opens by default. A tap opens
with it, a long press (or right click) on a file lists the others. The
open_media message takes an optional opener id; the client can only name a
player already configured for the file's type, and the command is still
rebuilt from the database. Tablets receive player names and kinds (never
the spec) and are notified on every change.

media_openers (one row per type) becomes media_players; existing settings
are migrated as unnamed players whose id is the type, so the old
PUT /api/media/openers/<type> keeps working. A type always keeps a player.

With real touch events the click following a long press landed on the
chooser backdrop (closing it at once) or on one of its buttons (opening a
player by mistake); clicks of the opening gesture are now ignored.

Tests: store, migration, REST, WebSocket choice and refusals, and a
Chromium test with touch long press, release click, Escape and right click.
The UI tests no longer leave /admin before the token is stored.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-30 17:28:04 +01:00
Denis 5921b7c414 Add the Media tab: browse sound, image and video files and open them on the PC
Media tab (needs at least one folder, hidden otherwise):
- Folders from [media] roots in config.toml, default = the user's Music, Videos
  and Pictures (XDG, never $HOME); [] disables the tab
- Icons per type, subfolders, breadcrumb, back, refresh, All/Sounds/Images/
  Videos filter; a tap opens the file on the PC (WebSocket system/open_media)
- Three special launchers (audio, image, video), editable on /admin: system
  default (gio open), installed application (gio launch) or a raw command
  (allow_custom_command); the file path is appended as the last argument
- The client never sends an absolute path: (root, relative path) is resolved
  server side; refuses "..", hidden entries, symlinks leaving the root, and
  anything but known media extensions (a script renamed .mp3 is refused)
- GET /api/media (Bearer token), listing runs in a thread, 1000 entries max

Interface cache: pages are revalidated (Cache-Control: no-cache) and static
files are served under /static/<version>/ (immutable cache), so a tablet can
no longer keep an old interface after an update. Reproduced and verified:
opening the same link serves the cached page, one refresh fixes it for good.

Refactors: restapi.py (shared REST helpers), AppPicker (shared by the launcher
and opener forms on /admin).

Tests: 159 (library escapes, openers, admin API, config, cache headers). Also
checked end to end with a real server (fake gio recording its arguments) and
headless Chromium. Not tried on the real tablet.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-26 13:32:37 +01:00
Denis e823b2d470 Initial commit: MediaDeck web remote for a Linux media PC
Python bridge (aiohttp, single asyncio loop) between a tablet browser and
a Linux media PC: MPRIS players, PipeWire audio (pactl), virtual keyboard
and touchpad (uinput), power and session control (logind).

- Tablet UI with player, audio, touchpad, launchers and system tabs (fr/en)
- Launchers stored in SQLite and managed from /admin; raw commands are
  opt-in (admin.allow_custom_command)
- Optional text entry, translated to key presses from the PC's real
  keyboard layout with libxkbcommon and never through the clipboard
  (features.text_input, off by default)
- Local HTTPS with a private CA restricted by name constraints (make cert)
- Token-protected WebSocket and REST API, strict CSP, no JS dependencies

Checked: pyright 0 errors, 87 unit tests, browser tests in headless
Chromium. Not yet exercised on the real tablet, nor with real uinput key
presses.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-23 23:33:10 +02:00