#!/usr/bin/env python3 """Print a LiveKit Meet URL + token so a speaker can join and share a screen. STUB / future: do not use until the production LiveKit server is online. The third display currently shows a placeholder only. """ from __future__ import annotations import argparse import sys from pathlib import Path from urllib.parse import quote, urlparse ROOT = Path(__file__).resolve().parents[1] if str(ROOT) not in sys.path: sys.path.insert(0, str(ROOT)) from config import load_config from tokens import make_speaker_token def public_url(cfg) -> str: if cfg.livekit_public_url: return cfg.livekit_public_url.rstrip("/") parsed = urlparse(cfg.url) host = parsed.hostname or "127.0.0.1" if host in ("127.0.0.1", "localhost"): host = "10.200.0.20" scheme = parsed.scheme or "ws" port = parsed.port if port: return f"{scheme}://{host}:{port}" return f"{scheme}://{host}" def main() -> int: ap = argparse.ArgumentParser(description=__doc__) ap.add_argument("--identity", default="", help="default: DISPLAY_SPEAKER_PARTICIPANT") ap.add_argument("--name", default="Speaker") args = ap.parse_args() cfg = load_config() identity = args.identity or cfg.display_speaker_participant or "speaker" token = make_speaker_token(cfg.api_key, cfg.api_secret, cfg.room, identity, args.name) url = public_url(cfg) meet = ( "https://meet.livekit.io/custom" f"?liveKitUrl={quote(url, safe='')}&token={quote(token, safe='')}" ) print(f"room: {cfg.room}") print(f"identity: {identity}") print(f"url: {url}") print(f"token: {token}") print() print("Open this on the speaker laptop, then Share screen:") print(meet) return 0 if __name__ == "__main__": raise SystemExit(main())