Skip to main content

Crate mochi_protocol

Crate mochi_protocol 

Source
Expand description

The Mochi protocol: messages exchanged over the daemon’s Unix socket.

Every message is one JSON object on one line. Clients send a ClientMessage, the daemon sends a DaemonMessage. Each object has a type field naming the variant in snake_case. docs/protocol.md describes the conversation in full.

The protocol only grows: new message types and new fields with defaults. Removing or renaming anything means a new API version.

Modules§

plugin
The conversation between mochid and a plugin backend.
spec
What modules hand the daemon: activities for the island, bubbles, and the parsed arguments of their actions. Builtin modules use these types directly; plugin backends send them as JSON, so they serialize too.
version
Mochi’s version, and the oldest one a theme, bento or plugin says it works with.

Structs§

ActionSpec
Activity
The activity the island shows.
ActivityId
Identifies one activity for its whole life, across the daemon and the UI.
AreaArrangement
An area that doesn’t lay its bubbles apart.
ArgSpec
Bubble
A bubble as the UI draws it. Snapshots list bubbles in drawing order: area by area, each from left to right. Consecutive bubbles with the same group share one pill.
BubbleId
Identifies one bubble for its whole life, across the daemon and the UI.
Click
A click outside the island, where it happened, to pass on.
Color
A color in the form QML accepts: #rrggbb or #aarrggbb.
ColorError
Colors
Color roles. The defaults are “Obsidian”: a black island that blends into the bezel, graphite layers on it, and one accent used sparingly.
CompositorStatus
What the daemon knows about the compositor.
Contribution
One thing a module offers another.
Layout
Where the island sits and what shape it takes. Sizes in logical pixels.
ModuleActions
Motion
Animation constants. The spring values feed QML’s SpringAnimation.
Notch
Settings for notch and bar modes.
Overflow
How many bubbles an area has beyond its maximum.
PluginStatus
One plugin from plugins.toml, as the daemon sees it.
Scroll
A wheel or touchpad scroll, as Qt reports it.
Stacking
How stacked areas behave, when any area stacks.
Status
Text
The type scale, in pixels: four sizes and one for big numbers. An empty family uses Inter, which Mochi’s packages bring, or the system font without it; an empty display_family keeps family.
Theme

Enums§

Anchor
The screen edge everything sits against.
Appearance
Which of a preset’s palettes to use.
Area
One of the five places along the edge, from left to right. The island sits in one of them too.
ArgKind
Arrangement
How an area draws its bubbles: [bubbles] left = "merged".
ClientMessage
Sent to the daemon.
DaemonMessage
Sent by the daemon.
ErrorCode
EventKind
Mode
PluginState
Role
Who is on the other end of a connection. It decides which messages the daemon accepts from it.

Constants§

API
The protocol version both sides announce in hello.
MAX_LINE
The longest line a reader should accept, in bytes. Anything longer is a broken or hostile peer.
RENAMED_MODULES
Module ids that changed, old first. The old id still works in config.toml, in commands and in plugin manifests, with a warning.
SOCKET_ENV
Overrides where clients look for the daemon’s socket. The daemon also sets it for the Quickshell process it starts.

Functions§

decode
Parses one line, with or without its trailing newline.
encode
Serializes a message as one line, including the trailing newline.
module_id
The current id of a module, for one named by its old id.
socket_path
$MOCHI_SOCKET, or else $XDG_RUNTIME_DIR/mochi/mochi.sock.