Queries
omniwmctl query <name> [selectors...] [--fields <field1,field2,...>] [--format json|ndjson|table|tsv|text]Default output format for queries is json.
Query Selectors
Section titled “Query Selectors”Selectors filter query results. Value selectors take an argument; boolean selectors are flags.
Value selectors:
| Selector | Description |
|---|---|
--window <id> |
Filter by session-scoped opaque window ID |
--workspace <name> |
Filter by workspace raw name, display name, or ID |
--display <name> |
Filter by display name or display ID |
--app <name> |
Filter by application display name |
--bundle-id <id> |
Filter by application bundle identifier |
Boolean selectors:
| Selector | Description |
|---|---|
--focused |
Only the focused item |
--visible |
Only visible items; windows also require a visible workspace, no window hidden state, an app that is not hidden, and no WindowServer ordered-out state |
--floating |
Only floating windows |
--scratchpad |
Only windows assigned to a scratchpad |
--current |
Only the current/interaction item |
--main |
Only the main display |
Query Fields
Section titled “Query Fields”Use --fields with a comma-separated list to limit returned fields.
Field tokens are part of the CLI contract. Returned JSON still uses the payload schema’s field names, so the selected token may not be byte-for-byte identical to the JSON key. For example, window-counts selects the workspace payload’s counts field.
Window fields: id, pid, window-id, workspace, display, app, title, frame, mode, layout-reason, manual-override, is-focused, is-fullscreen, is-visible, is-app-hidden, is-scratchpad, scratchpad-index, hidden-reason, column-index, focus-rank
window-id returns the JSON field windowId, the raw CGWindowID of the window. It is stable for the window’s lifetime but not session-scoped; keep using id for window actions.
For windows, is-visible is true only when the workspace is visible, the window has no hidden-reason, its macOS application is not hidden, and WindowServer has not reported the window as ordered out. If the WindowServer ordered-in state is unavailable, the other visibility checks determine the result. The --visible selector uses the same conditions.
hidden-reason selects the optional JSON field hiddenReason:
| Value | Meaning |
|---|---|
workspace-inactive |
Parked for an inactive workspace. |
tab-inactive |
Hidden as an inactive member of a Dwindle group or Niri tabbed column. |
layout-transient |
Other layout-owned hiding, including Niri columns outside the viewport and active members awaiting reveal. |
scratchpad |
Hidden by the scratchpad. |
Workspace and scratchpad hiding retain their reasons. For other layout hiding, an inactive tab reports tab-inactive even when its column is also outside the viewport. An active member awaiting reveal keeps layout-transient until its hidden state clears. hiddenReason is omitted when no hidden state is recorded; layout-transient can persist in a settled layout and is not an animation-completion signal.
is-app-hidden exposes the PID-scoped macOS hide state independently of layout-reason and hidden-reason; selecting is-app-hidden returns the JSON field isAppHidden.
is-fullscreen returns the JSON field isFullscreen: true while the window is in OmniWM’s own fullscreen (toggle-fullscreen) in its workspace’s active layout. Native macOS Full Screen is reported separately by layout-reason. The focused-window query always includes isFullscreen for the focused window.
column-index returns the JSON field columnIndex: the one-based Niri column that holds the window, numbered like focus-column and move-column-to-index. Inactive tabs share their column’s index; floating windows, Dwindle windows, and windows excluded from the layout, such as minimized windows, omit it.
focus-rank returns the JSON field focusRank: the window’s position in OmniWM’s focus history, where 0 is the most recently focused managed window. The history covers tiled, floating, and scratchpad windows, records every focus change OmniWM observes (commands, clicks, ⌘⇥, apps raising their own windows), drops closed windows, and starts empty when OmniWM launches. Ranks are global, so a filtered result can skip numbers. Windows not focused since launch omit focusRank.
Sorting Windows
Section titled “Sorting Windows”query windows --sort mru returns windows most recently focused first. Windows without a focus-rank follow in the default order (workspace, then layout). Without --sort, windows keep the default order. --sort is accepted only by the windows query.
Ranks are read when the query runs. A focus change alone does not emit windows-changed, so a focusRank in an event payload can be out of date; run query windows --sort mru when you need the current order.
Workspace fields: id, raw-name, display-name, number, layout, display, is-focused, is-visible, is-current, window-counts, focused-window-id, columns
The three workspace flags answer different questions. is-focused marks the workspace that holds the natively focused managed window, is-current marks the active workspace on the interaction monitor (the one --current selects), and is-visible marks every workspace that is active on some monitor. With two monitors, two workspaces are visible, one is current, and at most one is focused.
columns lists a Niri workspace’s columns in order as {"index": 1, "mode": "normal", "viewport": "before"} entries. mode is normal or tabbed. viewport is before or after for a column entirely outside the viewport on that side and intersecting for a column that is at least partly visible. It describes the viewport’s destination: a scroll animation reports its target immediately, and a trackpad drag keeps the previous value until release. Dwindle workspaces omit columns.
Display fields: id, name, is-main, is-current, frame, visible-frame, has-notch, orientation, inner-gap, outer-gap-left, outer-gap-right, outer-gap-top, outer-gap-bottom, fullscreen-uses-outer-gaps, active-workspace, uuid, notch, menu-bar-height, bar-frames, reserved-insets
uuid is the display’s stable UUID, notch the notch’s horizontal start and end, menu-bar-height the space above the visible frame, bar-frames the frames of the workspace bar panels shown on the display, and reserved-insets the space the workspace bar reserves for windows on each edge.
fullscreen-uses-outer-gaps reports the resolved per-display policy used by OmniWM Full Screen, Niri maximized, and the Single Window “Full Screen” fit. It does not affect native macOS Full Screen.
frame and visible-frame use AppKit global screen coordinates as reported by NSScreen: the origin is the bottom-left corner of the main display and y grows upward, so a display above the main one has a larger y than the main display. Window frame values use the same coordinate space.
Query Reference
Section titled “Query Reference”| Query | Selectors | Fields | Description |
|---|---|---|---|
workspace-bar |
— | — | Workspace bar projection for every monitor; app pills carry id, appName, bundleId (omitted when unknown), isFocused, windowCount, and allWindows |
active-workspace |
— | — | Current interaction monitor and active workspace |
focused-monitor |
— | — | Current interaction monitor and its active workspace |
apps |
— | — | Managed app summary |
metrics |
— | — | Always-on runtime metrics: AX frame-write attempts and whole-attempt wall time (the setter plus its ordering/verification reads; enhanced-UI batch work and the retry element refresh are not counted) as since-launch totals plus live rows per app AX context, display tick timing, layout build counts, and process energy/CPU. Populated without an active capture session |
focused-window |
— | — | Focused managed window snapshot |
windows |
--window, --workspace, --display, --focused, --visible, --floating, --scratchpad, --app, --bundle-id |
window fields | Managed windows |
workspaces |
--workspace, --display, --current, --visible, --focused |
workspace fields | Configured workspaces with occupancy |
displays |
--display, --main, --current |
display fields | Connected displays with geometry |
dwindle-tree |
— | — | The interaction workspace’s Dwindle tree; see Dwindle Tree |
rules |
— | — | Persisted user window rules |
rule-actions |
— | — | Rule action registry |
queries |
— | — | Query registry |
commands |
— | — | Automation action registry for command, workspace, window, window mark, window gather, dwindle, and shell surfaces |
subscriptions |
— | — | Subscription registry |
capabilities |
— | — | Full protocol capabilities, including windowMarkActions, windowGatherActions, dwindleActions, and shellActions |
shell-widgets |
— | — | Luau shell widgets with their state (loading, loaded, failed or fallback), placements, source file and any error, plus problems found in shell.luau and theme files |
commands and capabilities include the window mark descriptors. List live marks with omniwmctl window mark list.
Examples:
# List all windows on workspace 1omniwmctl query windows --workspace 1
# Get focused window in table formatomniwmctl query focused-window --format table
# List visible floating windows, only return id and titleomniwmctl query windows --visible --floating --fields id,title
# Safari windows, most recently focused firstomniwmctl query windows --bundle-id com.apple.Safari --sort mru --fields id,focus-rank,title
# Get the active workspace on the current interaction monitoromniwmctl query workspaces --current
# Check server capabilitiesomniwmctl query capabilitiesDwindle Tree
Section titled “Dwindle Tree”query dwindle-tree returns workspace, the interaction monitor’s active workspace, plus tree and tooLarge:
{ "workspace": { "id": "…", "rawName": "1", "displayName": "1", "number": 1 }, "tree": { "workspaceId": "…", "revision": "3F9A0C17E2B4D865", "preselect": "right", "nodes": [ { "kind": "split", "orientation": "horizontal", "ratio": 1 }, { "kind": "leaf", "members": ["<window id>"], "active": 1 }, { "kind": "leaf", "members": ["<window id>", "<window id>"], "active": 2 } ] }, "tooLarge": false}nodes lists the tree in preorder: each split is followed by its first and then its second subtree. The first is on the left of a horizontal split and at the bottom of a vertical one, and ratio is 1 for an even split. A leaf’s members are the session-scoped window IDs of its tile in tab order, and active is the position of the one shown, counting from 1. preselect is the pending direction (left, right, up or down) and is omitted when none is set. revision is 16 hex digits that change when the tree, a ratio, a tile’s windows or tab, or the preselect changes, and stay the same otherwise until OmniWM restarts.
An empty Dwindle workspace returns a tree with no nodes. tree is omitted on other layouts and until Dwindle has laid out the workspace’s current windows, for example right after one opens or closes. A tree with more than 256 windows omits tree and sets tooLarge to true.
Replace
Section titled “Replace”To change the layout, read the tree, edit it, and send it back as an IPC request with kind: "dwindle". There is no omniwmctl command for it. The payload is:
{ "name": "replace", "tree": { "workspaceId": "…", "revision": "3F9A0C17E2B4D865", "preselect": "left", "nodes": [ { "kind": "split", "orientation": "vertical", "ratio": 1.4 }, { "kind": "leaf", "members": ["<window id>", "<window id>"], "active": 1 }, { "kind": "leaf", "members": ["<window id>"], "active": 1 } ] }}tree has the same shape as the query’s. Omit preselect to clear it. OmniWM checks the whole tree before it changes anything:
revisionmust be the one you read, so a tree that changed in the meantime is refused.workspaceIdmust be the interaction workspace, and that workspace must use Dwindle.- The leaves must list every tiled window of that workspace once, by its ID from this session.
ratiomust be from 0 to 2, andactivemust point at one of the leaf’s windows.- The focused window, or one OmniWM is about to focus, must stay the shown tab of its tile.
- The windows’ minimum sizes must fit the display.
status: "executed" means OmniWM accepted the layout and asked for a relayout. Window frames settle afterwards. Sending the current tree unchanged returns no_change with status: "ignored". A refusal changes nothing and returns status: "error" with one of these codes:
| Code | Meaning |
|---|---|
invalid_arguments |
The tree is not one complete Dwindle tree: a split without two children, a leaf without windows, a missing or out-of-range ratio or active, a field that belongs to the other node kind, a revision that is not 16 hex digits, a workspaceId that is not a UUID, or more than 256 windows |
stale_revision |
The tree changed since revision was read |
wrong_workspace |
workspaceId is not the interaction workspace, or that workspace does not use Dwindle |
stale_window_id |
A window ID is malformed, comes from another session, or names a window OmniWM does not manage |
membership_mismatch |
The leaves skip a tiled window, repeat one, or list one from elsewhere |
ineligible_window |
A listed window is minimized, hidden, withdrawn, fullscreen, in a scratchpad, or on another macOS desktop |
focus_conflict |
The focused window, or one OmniWM is about to focus, would stop being the shown tab of its tile |
busy |
A mouse resize or move or a workspace swipe is running, or Dwindle has not laid out the workspace’s current windows yet; try again once it settles |
does_not_fit |
The windows’ minimum sizes do not fit the display in this layout |
While OmniWM is disabled or Overview is open, the request returns ignored_disabled or ignored_overview with status: "ignored".