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.1

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.1
File Size Uploaded Provenance Actions
glimpse_applet_sdk-0.13.1.tar.gz 14.3 kB With provenance Details for glimpse_applet_sdk-0.13.1.tar.gz

Built distribution (wheel)

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

Total release size: 30.8 kB

Release files / glimpse_applet_sdk-0.13.1.tar.gz

Download URL glimpse_applet_sdk-0.13.1.tar.gz
Size 14.3 kB
Tags Source
SHA-256 checksum
How to use checksums
66ab61f6fcc5623b8ef592cf7bee9ea9117a7efee373437c3890436278e542e1
BLAKE2b-256 checksum
How to use checksums
25cd2b1cf50436bf6cee73883806961495778899eb054a2f6fc64e015b9dba05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

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

Download URL glimpse_applet_sdk-0.13.1-py3-none-any.whl
Size 16.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8ef15e5ab1a90bd9de1d865bd856db8ee2230b274b3566216d65a5e67bf9484d
BLAKE2b-256 checksum
How to use checksums
7a5f11a30c1b5ed3dc9a95acfcc253bf1d72856e6536bda64fc852532efff62e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

Security for glimpse-applet-sdk 0.13.1

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for glimpse_applet_sdk-0.13.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

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