create_quad_layout
Generate a 2x2 window layout on a specified display for arranging four apps in top-left, top-right, bottom-left, and bottom-right positions using customizable layout names and app configurations.
Instructions
Create a quad (2x2) window layout on a specific display
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| apps | Yes | Array of 4 app names for TL, TR, BL, BR positions | |
| display | No | Which display to use | |
| layoutName | Yes | Name for the quad layout |
Implementation Reference
- src/index.js:433-512 (handler)The handler function that executes the create_quad_layout tool. It validates input (4 apps), generates AppleScript to position each app in a quadrant using Moom shortcuts, saves the layout via Moom, and returns success/error text.async createQuadLayout(layoutName, display = 'main', apps) { if (apps.length !== 4) { return { content: [{ type: 'text', text: 'Error: Quad layout requires exactly 4 apps' }] }; } const script = ` -- Rectangle shortcuts for quarters on topLeft() tell application "System Events" key code 32 using {control down, command down} -- U end tell end topLeft on topRight() tell application "System Events" key code 34 using {control down, command down} -- I end tell end topRight on bottomLeft() tell application "System Events" key code 38 using {control down, command down} -- J end tell end bottomLeft on bottomRight() tell application "System Events" key code 40 using {control down, command down} -- K end tell end bottomRight -- Position apps in quarters tell application "${apps[0]}" to activate delay 0.5 topLeft() delay 0.5 tell application "${apps[1]}" to activate delay 0.5 topRight() delay 0.5 tell application "${apps[2]}" to activate delay 0.5 bottomLeft() delay 0.5 tell application "${apps[3]}" to activate delay 0.5 bottomRight() delay 0.5 -- Save as Moom layout tell application "Moom" save layout and replace "${layoutName}" end tell `; try { await this.runAppleScript(script); return { content: [{ type: 'text', text: `Successfully created quad layout: ${layoutName}` }] }; } catch (error) { return { content: [{ type: 'text', text: `Error creating quad layout: ${error.message}` }] }; } }
- src/index.js:86-104 (schema)Input schema definition for the create_quad_layout tool, specifying parameters layoutName (string, required), display (enum, optional), apps (array of 4 strings, required).type: 'object', properties: { layoutName: { type: 'string', description: 'Name for the quad layout', }, display: { type: 'string', enum: ['main', 'left', 'right'], description: 'Which display to use', }, apps: { type: 'array', items: { type: 'string' }, description: 'Array of 4 app names for TL, TR, BL, BR positions', }, }, required: ['layoutName', 'apps'], },
- src/index.js:82-105 (registration)Tool registration in the ListTools response, defining name, description, and input schema for create_quad_layout.{ name: 'create_quad_layout', description: 'Create a quad (2x2) window layout on a specific display', inputSchema: { type: 'object', properties: { layoutName: { type: 'string', description: 'Name for the quad layout', }, display: { type: 'string', enum: ['main', 'left', 'right'], description: 'Which display to use', }, apps: { type: 'array', items: { type: 'string' }, description: 'Array of 4 app names for TL, TR, BL, BR positions', }, }, required: ['layoutName', 'apps'], }, },
- src/index.js:219-220 (registration)Dispatcher case in CallToolRequest handler that routes create_quad_layout calls to the handler function.case 'create_quad_layout': return await this.createQuadLayout(args.layoutName, args.display, args.apps);