Gizlet
Account
For agents

For agents · 5 min readMarkdown

Gizlet app and service runtime contract

Exact paths, environment variables, Runtime 1 libraries, input resolution, power leases, printing, local AI gateway, shutdown signals, and web player sandbox rules.

#runtime#environment#ai#input#agents

This reference answers what environment, filesystem paths, libraries, local services and lifecycle signals a Gizlet app or background service receives when launched on Gizlet OS, desktop Launchers, or the gizlet.io web player.

1. Foreground app environment (Gizlet OS)

Installed app packages live under /data/device/packages/apps/<id>/ (shared by all profiles, treat as read-only). Each profile's writable save directory lives at /run/gizlet/profile/apps/<id>/ (survives updates and uninstalls).

When launched, the working directory is the package folder and these environment variables are set:

GIZLET_APP_ID
Reverse-DNS package ID (e.g. io.gizlet.overeaten).
GIZLET_APP_DIR
Installed package root directory (same as cwd).
GIZLET_SAVE_DIR
Current profile's writable save/data directory. Store all persistent user state here.
GIZLET_LANG
Active profile language (zh-CN, en, etc.).
GIZLET_SWAP_AB
1 when A/B buttons are swapped, 0 otherwise.
GIZLET_INPUT_CONFIG
Set by desktop Launchers (and optionally on Gizlet OS) pointing to the current profile's input.json (version 1 schema from gizlet/device-input).

Dynamically linked executables run automatically through /data/device/runtime/1/bin/gizlet-run, providing Runtime 1's glibc, Mesa 25.0 (Panfrost / llvmpipe), libdrm, OpenGL ES 3.0, libraylib.so.600 (link with -l:libraylib.so.600), PDFium, and shared GizletSans-Regular.ttf / GizletSans-Bold.ttf fonts. Static executables and scripts (e.g. #!/usr/bin/bun) run directly.

2. Exit signals and Home button

  • Pressing Home (Fn) on a handheld closes the foreground app (or a service's settings app) and returns to the Launcher.
  • gizlet run sends SIGTERM, waits 3 seconds, then sends SIGKILL. Save progress promptly on SIGTERM.
  • Select and Start belong to the app—never reserve them for Launcher exit.

3. Input resolution

  • Native Rust/C apps should use gizlet/device-input (gizlet-device-input crate or C ABI), which resolves GIZLET_INPUT_CONFIG, GIZLET_SWAP_AB, evdev and desktop keys with one spec.
  • Engine ports and shell launchers can query /usr/bin/gizlet input resolve --json or --sh (eval "$(gizlet input resolve --sh)") to get GIZLET_SWAP_AB_RESOLVED, GIZLET_GAMEPAD_<BUTTON>, GIZLET_KEYBOARD_<TARGET>, and GIZLET_DEADZONE_LEFT/RIGHT.
  • Reserved desktop keys (cannot be bound): Escape, Tab, F1–F12, and modifier keys.

4. Background services (kind = "service")

Services are installed under /data/device/packages/services/<id>/, run by systemd as root with no display via gizlet service exec <id>, and require a full-screen settings binary (Gizlet OS v0.4.30+).

  • GIZLET_SERVICE_ID — Service ID.
  • GIZLET_SERVICE_DIR — Package folder (also cwd, treat as read-only).
  • GIZLET_STATE_DIR (and HOME) — /run/gizlet/profile/services/<id> (mode 0700, per profile, persists across updates and uninstalls).
  • GIZLET_RUNTIME_DIR — /run/gizlet-services/<id> (mode 0700, cleared on every start; keep sockets/PID files here).
  • Lifecycle: Stay in foreground; logs on stdout/stderr go to journal (gizlet service logs ID). Crash restarts after 2 s (up to 5/min); exit 0 stops cleanly. Stop/update/uninstall sends SIGTERM, then SIGKILL after 15 seconds. A new update that exits or fails within 3 s rolls back automatically.
  • Settings program: Receives all four GIZLET_SERVICE_* / STATE_DIR / RUNTIME_DIR variables plus GIZLET_LANG and GIZLET_SWAP_AB, runs full-screen at 640×480 with gamepad input, and exits on Home (Fn).

5. Power leases (/run/gizlet/power.sock)

Apps playing video or audio without button input can connect to Unix socket /run/gizlet/power.sock (any user) and send one line per request; closing the socket releases the lease automatically:

  • awake — Keeps screen on and blocks idle dimming/sleep; Power button still sleeps.
  • screen off — Turns backlight off without sleeping; inputs still reach the app, and Power key sends the line power to the app instead of sleeping.
  • screen on — Restores backlight while keeping power key delivery (send awake to return Power key to the OS).
  • release — Releases the lease so normal idle timers resume.
  • sleep — Sleeps immediately.
  • At 3% battery while discharging, gizlet-power sends battery-low and revokes all leases.

6. Network printing (gizlet print)

Apps submit PDFs (up to 64 MB) to the profile's default IPP Everywhere / AirPrint printer via CLI:

  • gizlet print submit FILE.pdf|- [--printer NAME] [--title TEXT] [--copies 1-99] [--media A4] [--sides ...] [--color color|monochrome] [--quality draft|normal|high] [--wait] [--json]
  • gizlet print status JOB [--json] · gizlet print cancel JOB · gizlet print printers [--json]

7. Built-in local AI gateway (http://127.0.0.1:8766/v1)

Point any OpenAI SDK at baseURL: "http://127.0.0.1:8766/v1" with any non-empty apiKey (e.g. "gizlet"). Supported endpoints: GET /v1/models, POST /v1/chat/completions (JSON or SSE stream: true), GET /v1/audio/voices?model=..., POST /v1/audio/speech, POST /v1/audio/transcriptions (request body ≤ 1 MiB, audio upload ≤ 26 MiB).

  • Use model gizlet/test for free fixed test replies, voice gizlet, a WAV chime, and fixed transcription without OpenRouter credits.
  • Error format: {"error": {"type", "code", "message"}} (message is already localized to the profile language). Key codes: 403 ai_disabled, 401 account_required, 401 account_expired, 403 openrouter_unlinked, 402 insufficient_credits, 429 rate_limited, 503 offline, 502 upstream_error, 413 request_too_large, 403 forbidden_origin.
  • Requests carrying browser Origin or non-none Sec-Fetch-Site are rejected (403 forbidden_origin).

8. Web player sandbox (wasm32-unknown-emscripten)

  • Served under /play/github.com/<owner>/<repo>/<tag>/ in an iframe sandboxed without allow-same-origin (no cookies, localStorage, or IndexedDB).
  • Reference package assets with relative paths; the only site-root import is /sdk/input/1.js (gizlet/device-input).
  • Read logical gamepad state via guest().poll() (never read DOM keyboard events directly—the outer player owns focus and user remappings from /controllers).
  • Persist saves via guest().storage after awaiting guest().ready.

Source files