Skip to content
brycehamrickPublic

About

Lightweight Swift CLI to tile stubborn macOS application windows.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

tile

A fast, zero-dependency Swift command-line utility that snaps and resizes active macOS windows using fractional screen coordinates.


Why tile?

macOS includes a native "Resize Window" action in the Shortcuts app, and power users frequently write AppleScript via System Events to manage window layouts. However, both of these native approaches fail on non-standard, custom application frameworks—most notably Adobe Creative Cloud apps (Audition, Photoshop, Premiere), Steam, and custom graphics canvases.

When targeting these apps, AppleScript and Shortcuts typically fail in two ways:

  1. Silent Failure: The command executes without error, but the window does not move because high-level AppleScript IPC wrappers are ignored by the app's custom UI engine.
  2. Crash Errors: The script throws System Events got an error: Can't get window 1... Invalid index. because non-native apps report 0 standard Cocoa (NSWindow) window objects to macOS.

The Solution

tile bypasses high-level AppleScript wrappers entirely. Built directly on top of macOS's native ApplicationServices framework, tile fetches the frontmost process ID and updates its low-level C Accessibility attributes (AXUIElementSetAttributeValue) directly. This forces even the most stubborn non-native application frames to instantly resize and reposition without requiring a heavy third-party menu-bar daemon running in the background.


Compilation & Installation

tile is written in Swift and uses system libraries built into macOS. You do not need Homebrew, Python, or external package managers.

1. Create the Source File

Save the Swift script code locally as tile.swift.

2. Compile the Binary

Open Terminal in the directory containing tile.swift and compile with optimizations enabled:

swiftc -O tile.swift -o tile

3. Move to System Path

Move the binary to /usr/local/bin so it can be called from anywhere:

sudo mv tile /usr/local/bin/tile

4. Verify Installation

which tile

Expected output: /usr/local/bin/tile


Command Reference

tile accepts four fractional parameters representing percentages of your display bounds (from 0.0 to 1.0):

tile <X_Position> <Y_Position> <Width_Fraction> <Height_Fraction>
Layout Command Description
Left Half tile 0 0 0.5 1 Left 50% of screen, full height
Right Half tile 0.5 0 0.5 1 Right 50% of screen, full height
Top Left Quarter tile 0 0 0.5 0.5 Top-left 25% of screen
Top Right Quarter tile 0.5 0 0.5 0.5 Top-right 25% of screen
Bottom Left Quarter tile 0 0.5 0.5 0.5 Bottom-left 25% of screen
Bottom Right Quarter tile 0.5 0.5 0.5 0.5 Bottom-right 25% of screen
Maximize tile 0 0 1 1 Fills 100% of available screen

macOS Shortcuts Integration

Follow these steps to map tile commands to global keyboard shortcuts using the native macOS Shortcuts app:

  1. Open the Shortcuts app on your Mac.
  2. Click + in the toolbar to create a new shortcut.
  3. In the right-hand action sidebar, search for Run Shell Script and drag it into the shortcut editor.
  4. Replace the default echo "Hello World" text with your desired command (e.g., /usr/local/bin/tile 0 0 0.5 0.5).
  5. In the right-hand sidebar, click the Shortcut Details icon (the i badge or sliders icon) and check Use as Quick Action.
  6. Click Add Keyboard Shortcut and press your desired hotkey combination (e.g., Option + Shift + Up Arrow).
  7. Name the shortcut (e.g., Tile Top Left) and close the window.

Accessibility Permissions

When running a shortcut for the first time, macOS may prompt you to grant Accessibility access. Navigate to System Settings > Privacy & Security > Accessibility and ensure Shortcuts (and Terminal, if testing via command line) is toggled On.

About

Lightweight Swift CLI to tile stubborn macOS application windows.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages