Name Chrome streams after their browser tabs

A browser extension reports audible tabs to moonmix-tabs-host, which matches
them to PipeWire streams by time and publishes the names for the mixer; streams
of one tab share a row. Ambiguous streams keep the browser's name. Without the
extension, a browser's only running stream shows its MPRIS title.

The smoke test no longer claims real audio hardware.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
nandiandClaude Opus 5.5 committed 2026-11-29 19:26:29 -08:00
1 parent b61d504234
commit e16cc1b2ad
31 files changed
+1830 -15

No files matched your search

+44
View File
@@ -0,0 +1,44 @@
#!/usr/bin/env python3
"""Smoke-test stand-in for a browser: plays a stream and reports it as a tab.
fake-browser.py <moonmix-tabs-host> <wav>: starts the host as its child, like a
browser does, then pw-play (its "audio service") and a moment later one audible
tab. Exits when stdin closes.
"""
import json
import os
import struct
import subprocess
import sys
import time
def message(tabs):
body = json.dumps({"tabs": tabs}).encode()
return struct.pack("=I", len(body)) + body
def play():
# exec keeps the pid the stream announces.
os.execvp("pw-play", ["pw-play", "-P", json.dumps({
"application.name": "Fake Browser",
"application.process.id": str(os.getpid()),
"media.name": "Playback",
}), sys.argv[2]])
host = subprocess.Popen([sys.argv[1]], stdin=subprocess.PIPE)
host.stdin.write(message([]))
host.stdin.flush()
time.sleep(3) # let it connect to PipeWire
audio = os.fork()
if audio == 0:
play()
time.sleep(0.5)
host.stdin.write(message([{"id": 7, "title": "Smoke test tab", "audible": True}]))
host.stdin.flush()
sys.stdin.read()
os.kill(audio, 15)
host.stdin.close()
host.wait(5)