webstation-broker
DeveloperPython referenceemulators

emulators.base

Emulator interface and shared launch plumbing.

Emulator interface and shared launch plumbing.

Defines the Emulator base class every launcher in this package subclasses, the environment apps are launched into, and the on-disk pid record that lets a broker process kill an emulator it never spawned.

attributelog
= logging.getLogger(__name__)
attributeXDG_RUNTIME_DIR
= os.environ.get('XDG_RUNTIME_DIR', '/config/.XDG')

The session's runtime directory, from XDG_RUNTIME_DIR (default /config/.XDG).

attributePID_FILE
= Path(os.environ.get('BROKER_PID_FILE', '/config/broker-emulator.json'))

Where the running emulator's pid is recorded, from BROKER_PID_FILE.

Defaults to /config/broker-emulator.json. The record exists so the emulator can still be killed by a broker process that never spawned it. Emulators are started in their own session, so nothing else ties them to the broker: a broker restart (an s6 bounce, or uvicorn --reload picking up an edit mid-session) otherwise leaves one playing with no handle on it, and the next launch stacks a second emulator on top of the first.

attributeSESSION_TAG_ENV
= 'WEBSTATION_SESSION_TAG'

Env var stamping a launched session, so what it starts can be found again at teardown.

Only the desktop sets it (see Desktop.launch). The desktop shell starts each app with a double fork, which leaves the app parented to pid 1 and sitting in a session whose leader has already exited, so nothing in the process tree ties it back to the session that started it. An inherited environment variable does, and survives the app re-execing itself, which the launcher-style entries in the menu do.

attributeWAYLAND_DISPLAY
= 'wayland-0'

labwc's socket under XDG_RUNTIME_DIR, the nested session every app renders into.

Selkies' own compositor listens on wayland-1 and labwc runs inside it as a client, so its whole desktop is what gets captured; an app that connects to wayland-1 directly sits outside the desktop.

attributeX_DISPLAY
= ':0'

The Xwayland server labwc hosts.

The container's own DISPLAY names the Xvfb server of the X11 image variant, which never starts in Wayland mode.

attributeSTATE_HEAD_BYTES
= 64

Bytes of a pushed state the push route hands check_state_bytes.

attributeDISC_RE
= re.compile('(?:^|[^a-z0-9])(?:disc|disk|cd)[\\s._-]*(\\d+)', re.IGNORECASE)

Matches a disc number in a path.

Disc numbering keeps a multi-disc game booting the same disc each session, so a save state taken for Disc 1 resumes on Disc 1.