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.
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_AB1when A/B buttons are swapped,0otherwise.GIZLET_INPUT_CONFIG- Set by desktop Launchers (and optionally on Gizlet OS) pointing to the current profile's
input.json(version 1 schema fromgizlet/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 runsendsSIGTERM, waits 3 seconds, then sendsSIGKILL. Save progress promptly onSIGTERM.- 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-inputcrate or C ABI), which resolvesGIZLET_INPUT_CONFIG,GIZLET_SWAP_AB, evdev and desktop keys with one spec. - Engine ports and shell launchers can query
/usr/bin/gizlet input resolve --jsonor--sh(eval "$(gizlet input resolve --sh)") to getGIZLET_SWAP_AB_RESOLVED,GIZLET_GAMEPAD_<BUTTON>,GIZLET_KEYBOARD_<TARGET>, andGIZLET_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 (alsocwd, treat as read-only).GIZLET_STATE_DIR(andHOME) —/run/gizlet/profile/services/<id>(mode0700, per profile, persists across updates and uninstalls).GIZLET_RUNTIME_DIR—/run/gizlet-services/<id>(mode0700, 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 sendsSIGTERM, thenSIGKILLafter 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_DIRvariables plusGIZLET_LANGandGIZLET_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 linepowerto the app instead of sleeping.screen on— Restores backlight while keepingpowerkey delivery (sendawaketo return Power key to the OS).release— Releases the lease so normal idle timers resume.sleep— Sleeps immediately.- At 3% battery while discharging,
gizlet-powersendsbattery-lowand 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/testfor free fixed test replies, voicegizlet, a WAV chime, and fixed transcription without OpenRouter credits. - Error format:
{"error": {"type", "code", "message"}}(messageis 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
Originor non-noneSec-Fetch-Siteare rejected (403 forbidden_origin).
8. Web player sandbox (wasm32-unknown-emscripten)
- Served under
/play/github.com/<owner>/<repo>/<tag>/in an iframe sandboxed withoutallow-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().storageafter awaitingguest().ready.