Skip to main content

glimpse-sdk for Python

Write a glimpse panel applet in Python. The applet is a Python program: the panel starts it as a systemd user unit, and the SDK speaks the panel's NDJSON protocol on the unix socket named by GLIMPSE_APPLET_SOCKET, which the panel sets; without it the applet exits with code 1. The wire format is specified in PROTOCOL.md and is shared with the TypeScript SDK.

from glimpse_sdk import Indicator, Popover, Row, Section, run


class App:
    def build(self, ctx):
        return [
            Indicator(icon="face-smile-symbolic", tooltip="Hello", children=["Hello"]),
            Popover(
                icon="face-smile-symbolic",
                title="Hello",
                children=[
                    Section(title="Hello", children=[Row(title="It works")]),
                ],
            ),
        ]


run(App())

Model

  • build(ctx) returns a fresh widget tree on every rebuild. Widgets are plain values: props flow down, callbacks (on_toggle, on_change, …) flow up.
  • Handlers mutate state; the runtime rebuilds after every host message and diffs the new tree against the mounted one, emitting one protocol commit per rebuild.
  • A widget keeps its identity across rebuilds when its kind and key match in the same parent. Keyed rows that reorder emit move, and their controlled-edit sequence follows them. A kind change at a slot unmounts and remounts. A move across parents is a remove plus an insert.
  • Controlled props (value, active, open, selected) always come from state. An event's seq is copied onto the confirming set; an event older than the last applied seq is dropped; a rejected edit still confirms, so the panel restores the state value.
  • notify and copy spawn notify-send and wl-copy from the applet process.
  • Subclass BaseApplet[YourState] with a frozen-dataclass state = YourState() and build(ctx); Applet.main() runs it. set_state(field=value) replaces the state, rebuilds when it changed, and writes the fields listed in persist to state.json (loaded before start). Call it on the loop thread; replace lists and dicts rather than mutating them.
  • An app may define async def start(self, ctx): it is spawned once after the host hello, with ctx.options and state_dir filled in. It is a one-shot setup hook: start long-running work from it with ctx.spawn(coro); spawned tasks are cancelled when the applet exits. Load saved state and run tickers, watchers and network loops there; keep build free of side effects.
  • The runtime is an asyncio loop. A handler may be async def, and ctx.spawn(coro) starts a background coroutine for network, D-Bus or timer work; both run on the loop, so they mutate state without locks. A rebuild follows each completion; a long-running task calls ctx.wake() after each state change. An exception in a spawned coroutine exits the applet with code 1, like a raising handler. Never block build or a handler: use an async library, or await asyncio.to_thread(fn, ...) for a blocking call. Plain threads call ctx.wake() after updating state; wake(), the host requests and the client-side helpers (notify, copy, …) are safe from any thread.
  • Nothing builds before the host hello. A handler that raises exits with code 1 and a tree over a protocol limit with code 70; a closed socket exits 0.

Distribution

An exec applet process reads its own directory, not a sibling SDK directory. The Python template declares glimpse-applet-sdk in PEP 723 metadata; its desktop entry runs uv run applet.py. The kitchen sink example resolves that dependency to the local SDK.

Example and tests

Run examples/kitchen_sink/ against an isolated second panel, never the session bar; see live-testing rules. just sdk-test tests the SDKs.

Python, Rust and Go share the diff, seq, and commit rules above and use the TypeScript SDK's protocol fixtures as the conformance oracle.

Metadata

Release files for glimpse-applet-sdk 0.13.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for glimpse-applet-sdk 0.13.0
File Size Uploaded Provenance Actions
glimpse_applet_sdk-0.13.0.tar.gz 14.3 kB Without provenance Details for glimpse_applet_sdk-0.13.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for glimpse-applet-sdk 0.13.0
File Interpreter ABI Platform Actions
glimpse_applet_sdk-0.13.0-py3-none-any.whl Python 3 none any Details for glimpse_applet_sdk-0.13.0-py3-none-any.whl

Total release size: 30.8 kB

Release files / glimpse_applet_sdk-0.13.0.tar.gz

Download URL glimpse_applet_sdk-0.13.0.tar.gz
Size 14.3 kB
Tags Source
SHA-256 checksum
How to use checksums
5163e38129dd605b5267849d167929068eb518f06ce11c76a2d26ddce16dc608
BLAKE2b-256 checksum
How to use checksums
bc188397d497eacf88900617c10a80c9cb564352ac7701caa94ad2974d810207
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / glimpse_applet_sdk-0.13.0-py3-none-any.whl

Download URL glimpse_applet_sdk-0.13.0-py3-none-any.whl
Size 16.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f6172fe1b146603fc8ad81d8ad2cdd67af055b37987c2d663741eac83352b735
BLAKE2b-256 checksum
How to use checksums
8c7936a578cf38f364cdc9e7ee4f7abd9fc50dd3900e69767b9b57ec30fe67ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for glimpse-applet-sdk 0.13.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page