ctl

Brief

Every Terminal Delight window listens on its own control socket, and the same binary is the client. terminal-delight ctl lets a script, a keybinding, a status bar or an agent's own shell change a running window.

terminal-delight ctl tab name "deploy"
terminal-delight ctl mcp status
terminal-delight ctl doc beside /home/you/notes/plan.md

It names and groups tabs, turns panes to their workbench, opens documents and edits their notes, reads and sets the MCP server's switches, picks a skin, and hands a new terminal to a window. Its bench commands act on a pane's bench as your typing and clicks would, so they reach the agent in it, and adopt can open a pane running a command. Each command gets one line back, ok or err with the reason. By default it talks to the windows on your active Hyprland workspace, or to the window you're running in for tab commands.

A live window refuses every command that acts as a person, and every MCP switch change, unless it was launched with TD_MCP_SCRIPTED=1. Status, paint, skin and MCP calls still work.

Technical lists every command and its reply.

Technical

The control socket

Each window, scratch windows included, listens at $XDG_RUNTIME_DIR/terminal-delight/ctl-<pid>.sock, in a directory kept at 0700. The client sends one line and reads one line back, then the connection closes. Most effects are queued to the window, so ok means the command was accepted; the bench and doc commands wait up to two seconds for the window to say what happened. The CLI checks your command against the window's grammar before sending, so a typo fails at once with the usage line.1

Which windows#

FlagTargets
noneEvery window on the active Hyprland workspace. For tabs: the window you're running in.
--workspace active|<name-or-id>The windows on that workspace.
--allEvery window with a socket.
--pid <N>One window.

tab … always means your own tab and refuses a scope flag. adopt and tabs go to the first target only; everything else goes to every target, and a paint toggle sent to several windows settles them all on one state. Each reply prints as <pid> <reply>. A window with no socket prints err no control socket (older build — reopen this terminal).

Exit codes: 0 when at least one window answered with something other than err; 2 when nothing matched or every reply was err; 1 for a usage error.

The client waits 800 ms for a reply. If a window takes longer, the client prints err unreachable … — swept stale socket and deletes that window's socket, although the window is alive. Until the window restarts, neither ctl nor terminal-delight mcp can reach it. The bench and doc commands and mcp rpc can take longer than that on a busy window. It's tracked in issue 796.

Commands#

After terminal-delight ctlReplyDoes
pingpongIs it there.
whoamiok <session> <window-pid>Which session a window holds.
paint on|off|toggleokThe palette overlay over every pane.
paint statuson or off
skin <name>, skin themeok <name>Pick a skin, or follow the theme's. An unknown name answers with the ones there are.
skin statusactive=<id> known=<ids>
skin snapshotone line of JSONThe skin the window is drawing right now, with active_skin, palette and custom_path.
bench on|off|toggleokEvery pane to its workbench, or its terminal.
bench choose <n>ok pane <n>, queued pane <n> — off screen until you look, or err …Answer the question waiting on a bench with option n (1 to 20).
bench submitSend the open round of answers.
bench say <text>Type a line to a pane's agent through its bench, and send it.
bench type <text>The same without sending.
bench probeok pane <n> ‖ …The bench's zones, its link-bearing text and its floating document, for a test to check.
bench click|hover <x> <y> [alt|ctrl|ctrl-alt]A pointer event at a window point, through the bench's own handlers.
doc here <path>Float a document over a pane. The path must be absolute.
doc beside <path>Open it in a pane beside the focused one.
doc closeClose a floating document. One holding unsaved notes is kept once, and the reply says so.
doc scroll <pixels>Scroll a floating document; negative scrolls up.
doc notesthe pane's answer and one line of JSONWhat an open brief shows of its notes: its state, the bar's counts and the map copy map gives.
doc note add <nid> <text>, doc note delete <nid> <text>like doc notesAdd or delete a note on a brief's element. Text that starts with " is read as a JSON string, so it can hold a newline.
doc concur <nid>, doc savelike doc notesPut a stamp down or peel it off; save the notes into the file.
mcp statusenabled=on writes=off expose=agents events=on
mcp on|off, mcp writes on|off, mcp expose all|agentsokChange the MCP server's switches, one at a time. They show on the agent wall and are saved with the session.
mcp rpc <json>the JSON-RPC answerOne MCP call. mcp-none for a notification.
mcp from <session> <pane|-> rpc <json>the JSON-RPC answerThe same, naming the caller, as the relay sends it. A session that isn't the window's is refused with -32001; - says the caller doesn't know its pane.
adopt --cwd <dir> [--run <cmd>]okOpen a new pane in a directory, running a command. Used by td-send, which moves an Omarchy terminal tile into a pane.
tab name [<text>]ok 1Name your own tab; no text clears it.
tab group <name>, tab ungroupok 1Put your own tab in a group, or take it out.
tabs <json>ok <n>Several tab operations at once; see below.

The bench and doc commands that act on one pane pick the focused pane when it qualifies, otherwise the first that does, the active tab's panes first. A pane marked off-limits to agents is never picked by the bench commands.2

Live windows and scripted windows#

A window reads TD_MCP_SCRIPTED once, when it starts. Unless it is exactly 1, the window refuses two families of commands from every caller.3

  • The six MCP switch changes: mcp on|off, mcp writes on|off and mcp expose all|agents. The reply begins err mcp on: nothing changed. Global MCP policy is a person's choice in the Threshing Floor (the agent counter, top right). The switches live in the Threshing Floor.
  • Everything that acts as a person: adopt, tabs and therefore tab name|group|ungroup, every bench command, and every doc command. The reply begins err bench say: refused. This verb acts as the person and names the door to use instead: an agent reaches another pane only along a Threshing Floor line.

ping, whoami, paint, skin, mcp status, mcp rpc and mcp from work on every window. A test rig launches its own window with TD_MCP_SCRIPTED=1; there the bench commands still skip panes that are read-only or off-limits to agents. The usage line also lists bench probe and bench click|hover, which 0.4.0 accepts without listing.

Tab operations#

tabs takes a JSON array, or {"ops": […]}. Each operation has an op:

opFields
namename, a string or null
groupgroup, and optionally color and text_color for a new group
ungroupnone
colorcolor and/or text_color; null clears
group_colorgroup, color, text_color
collapsegroup, collapsed

A tab operation names its tab with exactly one of tab (its index, which changes when tabs move) or pane (a shell pid in it, which doesn't). group_color and collapse act on a group by name and take neither. Colours are #rrggbb. An error says which operation failed: tabs: op 2: …. A pretty-printed list is re-sent as one line, so a file of operations works.

terminal-delight ctl tabs '[{"op":"name","pane":4121,"name":"api"},{"op":"group","pane":4121,"group":"backend","color":"#3ec6d1"}]'

What would prove this wrong#

Two kinds of ctl command reach a terminal's input, both on purpose. The bench commands act on a pane's bench as a person would: bench say sends a line to its agent, bench choose and bench submit press its answers, and bench click presses whatever is under the point, which can answer, pause or end the agent. adopt with --run opens a new pane running a command. bench type only fills the bench's composer. Any other route into a terminal is a bug, and so is a bench command reaching a pane marked off-limits to agents.

On a window launched without TD_MCP_SCRIPTED=1, any of those commands, or any MCP switch change, that gets past the socket is a bug.

Sources

  1. The grammar, the client and the replies: ctl.rs.
  2. How the bench and document commands pick a pane: main.rs.
  3. 0.5.0's fence: ctl.rs.