Skip to content

feat: add state variables per-app - #7

Merged
PyFlat-JR merged 3 commits into
mainfrom
feature/per-app-variables
Oct 19, 2026
Merged

PyFlat-JR merged 3 commits into
mainfrom
feature/per-app-variables

Conversation

@PyFlat-JR

@PyFlat-JR PyFlat-JR commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

Gives every app listed as an instance its own copy of the state variables. The system_media_* variables follow whatever is playing, so a "Now Playing" text bound to them jumps to a YouTube tab while VLC plays music. Closes #6.

  • Variables: every state variable except the app name, which the variable's name already carries: 11 per app.
    • Named after the app's display name, e.g. system_media_vlc_media_player_artist, shown as "VLC media player: Artist".
    • Two apps whose names would clash, or a name with no usable letters, get the instance's hash: system_media_firefox_1a2b3c4d_artist.
    • Volume and position are writable, like their Any app counterparts.
    • The existing system_media_* variables don't change.
  • Catalog, not eager variables: a provider may declare at most 256 eager variables and a declared id at most 64 characters, so the per-app variables are an on-demand catalog with no limit on apps.
    • One folder per app (IsContainer). The host only shows folders for a catalog that supports search, so DiscoverAsync also answers a search: every word typed must appear in the variable's name or its app's name.
    • Ids are system-media-<instance id>-<variable>, e.g. system-media-app-vlc-exe-2900ecd1-artist. The host stores the id of every linked variable, so AGENTS.md lists them as public API.
    • The name is only the suggested name of a linked variable (the host keeps its own copy), so it may follow a renamed app without breaking anything.
  • Values: pushed. AppVariablePublisher reads the subscribed variables once a second and sends the ones that changed. Each known app has its own StateSnapshotCache, so one read covers all of an app's variables.
  • Catalog reload: the plugin tells the host to reload the catalog when it connects and when an app appears or is renamed. Without the first, the host kept showing the catalog from before a plugin restart.
  • Display names: one string per variable (Variables.App.Artist = {app}: Artist). A localized argument nested inside another doesn't reach the host, which showed {variable}.
  • Conformance in demo mode: make conformance sets SYSTEM_MEDIA_DEMO, and demo mode also leaves out the mpv/SMPlayer source. The suite runs actions and writes variables, which paused, skipped and seeked whatever was playing on the machine. MDC0801 now skips, because demo actions write no log line.
  • Tests:
    • ids valid, unique, on demand and in their app's folder, including for long and empty slugs;
    • the pinned id and name;
    • names from the display name, the hash on a clash, and the hash when no letters are left;
    • search matches;
    • an id mapping back to the Any app variable it reads like;
    • the folder being a container that can't be bound;
    • display names carrying only the app name as plain text.
  • Docs: README (Variables) and AGENTS.md (orientation, public API, conformance in demo mode).

Checklist

  • I have read AGENTS.md.
  • make build and make test pass locally (0 warnings, 257 tests; 274 with -p:SystemMediaWindows=false).
  • make conformance passes (32 passed, 0 failed; MDC0802 is inconclusive, as on main).
  • I updated README.md / AGENTS.md if this changes what they describe.

Tested on

Macro Deck 3 host, Windows 11, with VLC and Firefox playing at once:

  • each app has its own folder of variables in the variable list;
  • linked variables keep showing their own app's track.

@PyFlat-JR
PyFlat-JR merged commit 085cf29 into main Oct 19, 2026
3 checks passed
@PyFlat-JR
PyFlat-JR deleted the feature/per-app-variables branch October 19, 2026 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Idea - Different variables for data from different players

1 participant