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.
attributeSHELL_ID_ENV= 'SELKIES_SHELL_ID'Env var selkies sets on its desktop shell, inherited by what the shell launches.
attributeSESSION_DESKTOP= 'selkies'The XDG_CURRENT_DESKTOP selkies sets on the session's apps but not its services.
attributeAUTOSTART_LOCK= Path(XDG_RUNTIME_DIR) / 'selkies-autostart.lock'Lock file held open by whatever the container's autostart started.
attributeSESSION_ENV_FILE= Path(XDG_RUNTIME_DIR) / 'selkies-session-env.json'Where selkies writes the environment it starts the session's apps in.
attributeWAYLAND_DISPLAY= 'wayland-0'The socket under XDG_RUNTIME_DIR apps render into when the session names none.
The selkies session environment (see _session_env) names the session's
socket itself and wins when it does; this is the fallback for a selkies
without the session mode API, or a session file that leaves it out.
attributeX_DISPLAY= ':0'The session's Xwayland server when the session names none.
Like WAYLAND_DISPLAY, a fallback for the session file's own DISPLAY. The
container's own DISPLAY is never used: it can name the Xvfb server of the X11
image variant, which never starts in Wayland mode.
attributeSTATE_HEAD_BYTES= 64Bytes 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.