list_windows
List all visible windows with detailed properties such as ID, PID, desktop, geometry, hostname, and title for window management and automation.
Instructions
List all visible windows with id, pid, desktop, geometry (x/y/width/height), hostname, and title.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- server.js:160-183 (handler)The main handler function for the 'list_windows' tool. It requires 'wmctrl', executes 'wmctrl -l -G -p' to list all visible windows, parses the output into structured objects (id, desktop, pid, x, y, width, height, host, title), and returns the result as text.
async function listWindows() { const missing = requireBin('wmctrl'); if (missing) return errorResult(missing); const r = await run(BIN.wmctrl, ['-l', '-G', '-p']); if (r.code !== 0) return errorResult(`wmctrl failed: ${r.stderr || r.stdout}`); const entries = r.stdout.split('\n').filter(Boolean).map((line) => { // Format: <id> <desktop> <pid> <x> <y> <width> <height> <host> <title...> const parts = line.split(/\s+/); if (parts.length < 9) return null; const [id, desktop, pid, x, y, w, h, host, ...titleParts] = parts; return { id, desktop: parseInt(desktop, 10), pid: parseInt(pid, 10), x: parseInt(x, 10), y: parseInt(y, 10), width: parseInt(w, 10), height: parseInt(h, 10), host, title: titleParts.join(' '), }; }).filter(Boolean); return textResult({ windows: entries }); } - server.js:397-402 (schema)Tool registration object defining the 'list_windows' schema: name, description (lists visible windows with geometry/metadata), annotations (title, readOnlyHint), and an empty inputSchema (no required parameters).
{ name: 'list_windows', description: 'List all visible windows with id, pid, desktop, geometry (x/y/width/height), hostname, and title.', annotations: { title: 'List windows', readOnlyHint: true }, inputSchema: { type: 'object', properties: {} }, }, - server.js:553-555 (registration)The HANDLERS map that wires the tool name 'list_windows' to the listWindows handler function for dispatching.
const HANDLERS = { screenshot, list_windows: listWindows,