Developer builds one-command script to snap 8 Terminal windows into ultrawide grid
A developer working with multiple Claude Code sessions on a 3440×1440 ultrawide monitor created a shell script to automatically arrange eight Terminal.app windows into a 4×2 grid with a single command. The manual process of dragging windows into position each morning was taking about a minute, prompting the automation effort. The solution combines Swift and AppleScript, using Swift to handle coordinate-system conversion between macOS's Cocoa Y-up framework and AppleScript's Y-down global coordinates. Implementation revealed five key traps, including silent failures in AppleScript's set position command, incorrect window heights, and a missing 30-pixel menu bar offset on non-primary screens. The script resolves these issues through a convergence loop that re-scans window indexes on every pass rather than relying on names or IDs.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.


Discussion (0)
Log in to join the discussion and vote.
Log in