Skip to content
  1. Docs
  2. enzimOS
  3. Developers

Activity service

The enzui activity v1 protocol that lets apps publish background work progress for the shell to display, and how enzimos-activityd implements it.

The activity service is a small per-user broker for transient work status. Applications publish progress for jobs such as a file copy; the desktop shell subscribes and decides when to show it, based on real compositor focus. A large copy can stay quiet while its window is active and appear in the shell once you switch elsewhere. Layout and presentation remain the shell's responsibility.

enzimOS ships enzimos-activityd as the broker. The wire protocol, enzui activity v1, is framework-neutral, so enzUI applications on other systems can publish to any broker that implements it.

The service has no root component, no history on disk, no network access and no polling. It does not launch applications, access files or expose actions. Job content is not logged.

Transport

  • A persistent Unix stream socket at $XDG_RUNTIME_DIR/enzui-activity/service.sock. Clients may honour ENZUI_ACTIVITY_SOCKET as an override.
  • Private 0700 directory and 0600 socket; the daemon also checks the peer UID with SO_PEERCRED.
  • Messages are UTF-8 JSON frames terminated by LF, at most 32768 bytes per request.
  • Unknown fields, versions and enum values are rejected.

The daemon also serves the deprecated $XDG_RUNTIME_DIR/enzimos-activity/service.sock as a second listener sharing the same job set. New clients must use the neutral path; the legacy listener will be removed once clients have migrated.

Publishing work

Open one connection per app instance, from the UI process rather than a transfer worker:

json
{"op":"publish","version":1,"app_id":"io.github.enzui.Files"}

The server answers with its limits:

json
{"op":"ready","version":1,"lease_ms":90000,"heartbeat_ms":30000,"rate_per_second":4,"burst":8}

Then send complete replacement values for a job key that is unique within your connection:

json
{"op":"upsert","work":{"job":"copy-1","label":"Copying files","detail":"42 items","state":"running","progress":{"done":1048576,"total":8388608,"unit":"bytes"},"eta_ms":15000,"window_token":null}}
FieldRules
jobRequired. 1–64 ASCII alphanumerics or ._-
labelRequired. 1–96 UTF-8 bytes
stateRequired. running or paused
detailOptional, up to 160 bytes, default empty
progressnull for indeterminate work, or {done, total, unit} with nonzero total, 0 <= done <= total and unit bytes, items or steps
eta_msOptional producer estimate, at most 7 days. The broker never invents one.
window_tokenOptional opaque window identity, up to 128 bytes

app_id is at most 128 ASCII bytes in dotted, nonempty segments. Control characters and bidi overrides are refused in text. Do not send sensitive paths, names, credentials or command output; icons and executable names cannot be supplied.

Every accepted command returns {"op":"ack","revision":N,"changed":true|false}. Further commands:

json
{"op":"heartbeat"}
{"op":"finish","job":"copy-1","outcome":"succeeded"}
{"op":"remove","job":"copy-1"}

Outcomes are succeeded, failed or cancelled. To update several jobs at once, send {"op":"batch","works":[…]} with 1–16 distinct keys; the batch is applied atomically and counts as one command.

Lifetimes and budgets

  • Jobs belong to the connection. Another connection cannot change them, even with the same app_id and key.
  • Disconnecting removes all of the connection's jobs immediately.
  • Unfinished jobs expire after 90 seconds without renewal. Any valid update refreshes the lease; send a heartbeat every 30 seconds while running or paused jobs exist.
  • Finished jobs remain visible for 4 seconds, then expire. Keep the connection open so the shell can show completion.
  • Limits: 16 jobs per publisher, 64 jobs in total, 64 connections. Each publisher may send 4 commands per second with a burst of 8; exceeding that sends rate_limit and closes the connection. Coalesce changes into at most one batch per second.

Errors take the form {"op":"error","code":"…"} with one of invalid_hello, invalid_command, invalid_work, unknown_job, finished_job, job_limit, invalid_batch or rate_limit. Job-level errors leave the connection open; protocol violations close it.

Subscribing

The shell subscribes with:

json
{"op":"subscribe","version":1}

It then receives complete snapshots, initially and after every change:

json
{"op":"snapshot","version":1,"generation":"INSTANCE","revision":1,"jobs":[{"id":"1:copy-1","app_id":"io.github.enzui.Files","peer_pid":1234,"work":{"job":"copy-1","label":"Copying files","detail":"42 items","state":"running","progress":{"done":1048576,"total":8388608,"unit":"bytes"},"eta_ms":15000,"window_token":null},"outcome":null,"age_ms":200}]}

Subscribers send nothing further. Intermediate snapshots may be coalesced, so keep only the latest. IDs and revisions are valid only within a generation; a daemon restart starts a new generation with an empty state. A subscriber that stops reading is disconnected after a 2-second blocked write, and the handshake must complete within 10 seconds.

age_ms is the monotonic time since the job last changed. A shell may count an ETA down from it, but should not do so while a job is paused.

Focus and identity

SO_PEERCRED authenticates the user and provides peer_pid. App IDs, labels and window tokens are declared metadata, not verified identity, and must never be used to authorize privileged actions.

The broker publishes all jobs and accepts no focus commands. The shell uses its own compositor's active surface and owner PID to hide work belonging to the focused window, recomputing on each focus change without asking apps to republish. If no verified window_token is available, it falls back to grouping by PID, which cannot tell apart two windows of the same process. Turning the shell's activity surface off unsubscribes; the work itself continues.

LauncherEntry bridge

Apps that already emit Unity LauncherEntry progress on the session bus (com.canonical.Unity.LauncherEntry.Update), as many browsers, mail and chat clients do, are bridged into ordinary jobs without changes. While an entry has progress-visible set and a finite progress between 0 and 1, it appears as one job:

  • app_id is the desktop ID from application://ID.desktop.
  • job is launcher-progress.
  • label is the installed desktop entry's Name=, or "In progress".
  • progress is {done: round(progress*1000), total: 1000, unit: "steps"}.
  • peer_pid is the sender's bus PID, so focus suppression works as usual.

Updates are coalesced at 500 ms, and at most 32 entries are tracked. Badge count and urgent are not bridged.

Running locally

sh
cargo build --release --locked --offline -j 2
mkdir -m 700 -p .local/runtime
target/release/enzimos-activityd --socket "$PWD/.local/runtime/service.sock"

In separate terminals, start the example observer and a synthetic publisher:

sh
python examples/shell_observer.py --socket "$PWD/.local/runtime/service.sock"
python examples/copy_demo.py --socket "$PWD/.local/runtime/service.sock"

The observer's --focused-pid PID and --focused-window-token TOKEN options simulate compositor focus, and --disabled simulates the shell setting being off. The demo copies no files. A minimal publisher in Python:

python
import json, os, socket

path = os.environ.get("ENZUI_ACTIVITY_SOCKET") or os.environ["XDG_RUNTIME_DIR"] + "/enzui-activity/service.sock"
with socket.socket(socket.AF_UNIX) as s:
    s.connect(path)
    replies = s.makefile("rb")
    def send(value):
        s.sendall(json.dumps(value).encode() + b"\n")
        reply = json.loads(replies.readline())
        if reply["op"] == "error":
            raise RuntimeError(reply["code"])
    send({"op": "publish", "version": 1, "app_id": "io.github.enzui.Files"})
    send({"op": "upsert", "work": {"job": "demo-copy", "label": "Copying files", "state": "running",
                                   "progress": {"done": 3, "total": 10, "unit": "items"}}})
    send({"op": "finish", "job": "demo-copy", "outcome": "succeeded"})

Installed service

The package installs enzimos-activityd with a systemd user unit that serves both sockets, runs only for login users and applies ProtectSystem=strict, read-only home, RestrictAddressFamilies=AF_UNIX, MemoryMax=32M and TasksMax=8. It is enabled for normal desktop accounts and not started in the installer or recovery environments.

Sandboxed apps need an explicit socket policy to publish; they should not be given broad filesystem access for this purpose.