Convert Figma logo to code with AI

rxhanson logoRectangle

Move and resize windows on macOS with keyboard shortcuts and snap areas

25,585
763
25,585
84

Top Related Projects

23,088

A tiling window manager for macOS based on binary space partitioning

14,622

Automatic tiling window manager for macOS à la xmonad.

4,361

A lightweight macOS window and app manager scriptable with JavaScript

5,530

Managing windows size and position in OSX

11,205

An ultra-light MacOS utility that helps hide menu bar icons

Quick Overview

Rectangle is an open-source window management app for macOS. It allows users to easily resize and move windows using keyboard shortcuts or a menu bar icon, enhancing productivity and screen organization.

Pros

  • Customizable keyboard shortcuts for various window actions
  • Supports multiple displays and spaces
  • Lightweight and efficient, with minimal system resource usage
  • Free and open-source

Cons

  • Limited to macOS platform
  • May conflict with some native macOS window management features
  • Learning curve for users new to window management tools
  • Some advanced features require a paid upgrade to Rectangle Pro

Getting Started

  1. Download Rectangle from the GitHub releases page or the Mac App Store.
  2. Open the downloaded file and drag Rectangle to your Applications folder.
  3. Launch Rectangle from your Applications folder.
  4. Grant the necessary permissions when prompted (Accessibility and Screen Recording).
  5. Use the default keyboard shortcuts or customize them in the Rectangle preferences.

Example shortcuts:

  • Ctrl + Option + ←: Left Half
  • Ctrl + Option + →: Right Half
  • Ctrl + Option + ↑: Top Half
  • Ctrl + Option + ↓: Bottom Half
  • Ctrl + Option + Return: Maximize

For more information and advanced usage, refer to the Rectangle documentation.

Competitor Comparisons

23,088

A tiling window manager for macOS based on binary space partitioning

Pros of yabai

  • More advanced window management features, including automatic tiling and window stacking
  • Highly customizable with scripting support for complex workflows
  • Supports multiple desktop spaces and external monitors with granular control

Cons of yabai

  • Steeper learning curve and more complex setup process
  • Requires disabling System Integrity Protection (SIP) for full functionality
  • May have compatibility issues with some macOS versions and updates

Code Comparison

Rectangle:

func moveWindowToCenter() {
    if let screen = NSScreen.main {
        let visibleFrame = screen.visibleFrame
        window.setFrame(visibleFrame, display: true, animate: true)
    }
}

yabai:

yabai -m window --grid 4:4:1:1:2:2

Summary

Rectangle is a simpler, more user-friendly window management tool that works out of the box on macOS. It's ideal for users who want basic window snapping and resizing functionality without complex setup or customization.

yabai, on the other hand, is a powerful tiling window manager that offers advanced features and extensive customization options. It's better suited for power users and developers who are willing to invest time in configuring their window management system and don't mind potential compatibility issues.

Both tools have their merits, and the choice between them depends on the user's needs, technical expertise, and desired level of control over their window management experience.

14,622

Automatic tiling window manager for macOS à la xmonad.

Pros of Amethyst

  • Offers automatic tiling window management
  • Supports multiple layouts and workspaces
  • Highly customizable through a YAML configuration file

Cons of Amethyst

  • Steeper learning curve for new users
  • May consume more system resources due to constant monitoring
  • Less intuitive for users who prefer manual window management

Code Comparison

Amethyst (Swift):

override func layoutManager(layout: Layout) -> LayoutManager {
    return TilingLayoutManager(layout: layout)
}

Rectangle (Swift):

func resizeWindowToCenter() {
    let screenFrame = NSScreen.main?.visibleFrame ?? .zero
    let newFrame = NSRect(x: screenFrame.midX - windowFrame.width / 2,
                          y: screenFrame.midY - windowFrame.height / 2,
                          width: windowFrame.width,
                          height: windowFrame.height)
    window.setFrame(newFrame, display: true)
}

Key Differences

  1. Functionality: Amethyst focuses on automatic tiling, while Rectangle provides manual window management shortcuts.
  2. User Interface: Rectangle offers a more traditional, user-friendly interface, whereas Amethyst relies on keyboard shortcuts and configuration files.
  3. Customization: Amethyst provides more advanced customization options through its YAML configuration, while Rectangle offers simpler, built-in preferences.
  4. Resource Usage: Rectangle generally uses fewer system resources as it only activates when called upon, unlike Amethyst's constant monitoring.
  5. Learning Curve: Rectangle is easier for beginners to pick up and use immediately, while Amethyst requires more time to master its tiling concepts and shortcuts.
4,361

A lightweight macOS window and app manager scriptable with JavaScript

Pros of Phoenix

  • More customizable and extensible through Lua scripting
  • Offers advanced features like window layouts and multi-monitor support
  • Provides a REPL for interactive configuration and testing

Cons of Phoenix

  • Steeper learning curve due to Lua scripting requirement
  • Less user-friendly for those seeking a simple, out-of-the-box solution
  • Smaller community and fewer pre-built configurations available

Code Comparison

Phoenix (Lua):

local hyper = {"cmd", "alt", "ctrl"}
hs.hotkey.bind(hyper, "Left", function()
  local win = hs.window.focusedWindow()
  local f = win:frame()
  local screen = win:screen()
  local max = screen:frame()
  f.x = max.x
  f.y = max.y
  f.w = max.w / 2
  f.h = max.h
  win:setFrame(f)
end)

Rectangle (Swift):

@objc func leftHalf(_ sender: Any?) {
    if let screen = NSScreen.main {
        let visibleFrame = screen.visibleFrame
        let newFrame = NSRect(x: visibleFrame.origin.x,
                              y: visibleFrame.origin.y,
                              width: visibleFrame.width / 2,
                              height: visibleFrame.height)
        window.setFrame(newFrame, display: true, animate: true)
    }
}

Both repositories offer window management solutions for macOS, but they cater to different user preferences. Phoenix provides more flexibility and power through Lua scripting, while Rectangle offers a simpler, more accessible approach for users who prefer a straightforward window management tool.

5,530

Managing windows size and position in OSX

Pros of ShiftIt

  • Lightweight and simple to use
  • Supports older macOS versions (10.6+)
  • Customizable keyboard shortcuts

Cons of ShiftIt

  • No longer actively maintained (last update in 2016)
  • Limited window management options compared to Rectangle
  • Lacks advanced features like snap areas and multi-monitor support

Code Comparison

ShiftIt (Objective-C):

- (void)moveToTopHalf {
    CGRect screenRect = [self screenRect];
    screenRect.size.height /= 2;
    [self.window setFrame:screenRect display:YES animate:YES];
}

Rectangle (Swift):

func topHalf() {
    if let screen = window.screen {
        let visibleFrameOfScreen = screen.visibleFrame
        window.setFrame(NSRect(x: visibleFrameOfScreen.minX,
                               y: visibleFrameOfScreen.minY + visibleFrameOfScreen.height / 2,
                               width: visibleFrameOfScreen.width,
                               height: visibleFrameOfScreen.height / 2), display: true, animate: true)
    }
}

Summary

While ShiftIt is a simple and lightweight window management tool, Rectangle offers more features and active development. Rectangle provides advanced functionality like snap areas, multi-monitor support, and a modern codebase in Swift. ShiftIt may be suitable for users with older macOS versions or those preferring a minimalist approach, but Rectangle is generally the more robust and feature-rich option for most users.

11,205

An ultra-light MacOS utility that helps hide menu bar icons

Pros of Hidden

  • Focuses specifically on hiding menu bar icons, providing a cleaner desktop experience
  • Lightweight and simple to use, with a straightforward interface
  • Allows for customizable keyboard shortcuts to toggle icon visibility

Cons of Hidden

  • Limited functionality compared to Rectangle's window management features
  • May not be as actively maintained, with fewer recent updates
  • Lacks advanced customization options for window snapping and sizing

Code Comparison

Hidden (Swift):

func toggleHidden() {
    isHidden.toggle()
    updateStatusItem()
    updateMenuItems()
}

Rectangle (Swift):

func snapWindows(_ action: SnapAction) {
    let windows = AccessibilityElement.windowsInOrderOnScreen()
    for window in windows {
        window.snap(with: action)
    }
}

Hidden focuses on toggling visibility of menu bar icons, while Rectangle provides more complex window management functions. The code snippets reflect their different purposes, with Hidden's code being simpler and more focused on a single task, while Rectangle's code demonstrates its ability to handle multiple windows and perform various snapping actions.

Both projects are open-source and written in Swift, making them suitable for macOS development. However, Rectangle offers a broader range of features for window management, while Hidden excels in its specific niche of menu bar icon management.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Rectangle

Build

Rectangle is a window management app based on Spectacle, written in Swift.

Screenshot

System Requirements

Rectangle supports macOS v10.15+. The last version that is supported for macOS 10.13 and 10.14 is https://github.com/rxhanson/Rectangle/releases/tag/v0.73.

Installation

You can download the latest dmg from https://rectangleapp.com or the Releases page.

Or install with brew cask:

brew install --cask rectangle

How to use it

The keyboard shortcuts are self explanatory, but the snap areas can use some explanation if you've never used them on Windows or other window management apps.

Drag a window to the edge of the screen. When the mouse cursor reaches the edge of the screen, you'll see a footprint that Rectangle will attempt to resize and move the window to when the click is released.

Snap AreaResulting Action
Left or right edgeLeft or right half
TopMaximize
CornersQuarter in respective corner
Left or right edge, just above or below a cornerTop or bottom half
Bottom left, center, or right thirdRespective third
Bottom left or right third, then drag to bottom centerFirst or last two thirds, respectively

Ignore an app

  1. Focus the app that you want to ignore (make a window from that app frontmost).
  2. Open the Rectangle menu and select "Ignore app"

Execute an action by URL

Open the URL rectangle://execute-action?name=[name]. Do not activate Rectangle if possible.

Available values for [name]: left-half, right-half, center-half, top-half, bottom-half, top-left, top-right, bottom-left, bottom-right, first-third, center-third, last-third, first-two-thirds, last-two-thirds, maximize, almost-maximize, maximize-height, smaller, larger, center, restore, next-display, previous-display, move-left, move-right, move-up, move-down, first-fourth, second-fourth, third-fourth, last-fourth, first-three-fourths, last-three-fourths, top-left-sixth, top-center-sixth, top-right-sixth, bottom-left-sixth, bottom-center-sixth, bottom-right-sixth, specified, reverse-all, top-left-ninth, top-center-ninth, top-right-ninth, middle-left-ninth, middle-center-ninth, middle-right-ninth, bottom-left-ninth, bottom-center-ninth, bottom-right-ninth, top-left-third, top-right-third, bottom-left-third, bottom-right-third, top-left-eighth, top-center-left-eighth, top-center-right-eighth, top-right-eighth, bottom-left-eighth, bottom-center-left-eighth, bottom-center-right-eighth, bottom-right-eighth, tile-all, cascade-all

Example, from a shell: open -g "rectangle://execute-action?name=left-half"

Terminal Commands for Hidden Preferences

See TerminalCommands.md

Differences with Spectacle

  • Rectangle uses MASShortcut for keyboard shortcut recording. Spectacle used its own shortcut recorder.
  • Rectangle has additional window actions: move windows to each edge without resizing, maximize only the height of a window, almost maximizing a window.
  • Next/prev screen thirds is replaced with explicitly first third, first two thirds, center third, last two thirds, and last third. Screen orientation is taken into account, as in first third will be left third on landscape and top third on portrait.
    • You can however emulate Spectacle's third cycling using first and last third actions. So, if you repeatedly execute first third, it will cycle through thirds (first, center, last) and vice-versa with the last third.
  • There's an option to have windows traverse across displays on subsequent left or right executions.
  • Windows will snap when dragged to edges/corners of the screen. This can be disabled.

Common Known Issues

Rectangle doesn't have the ability to move to other desktops/spaces

Apple never released a public API for Spaces. Other apps that move windows between spaces use unsupported or undesirable ways to achieve this. If Apple decides to release a public API for it, I'll add it in.

Window resizing is off slightly for iTerm2

By default iTerm2 will only resize in increments of character widths. There might be a setting inside iTerm2 to disable this, but you can change it with the following command.

defaults write com.googlecode.iterm2 DisableWindowSizeSnap -integer 1

Rectangle appears to cause Notification Center to freeze

This appears to affect only a small amount of users. To prevent this from happening, uncheck the box for "Snap windows by dragging". See issue 317.

Troubleshooting

If windows aren't resizing or moving as you expect, here's some initial steps to get to the bottom of it. Most issues of this type have been caused by other apps.

  1. Make sure macOS is up to date.
  2. Restart your machine (this often fixes things right after a macOS update).
  3. Make sure there are no other window manager applications running.
  4. Make sure that the app whose windows are not behaving properly does not have any conflicting keyboard shortcuts.
  5. Try using the menu items to execute a window action or changing the keyboard shortcut to something different so we can tell if it's a keyboard shortcut issue or not.
  6. Enable debug logging, as per the instructions in the following section.
  7. The logs are pretty straightforward. If your calculated rect and your resulting rect are identical, chances are that there is another application causing issues. Save your logs if needed to attach to an issue if you create one.
  8. If you suspect there may be another application causing issues, try creating and logging in as a new macOS user.

Try resetting the macOS accessibility permissions for Rectangle:

tccutil reset All com.knollsoft.Rectangle

Or, this can be done with the following steps instead of the tccutil terminal command.

  1. Close Rectangle if it's running
  2. In System Settings -> Privacy & Security -> Accessibility, first disable Rectangle, then remove it with the minus button. (it's important to do both of those steps in that order)
  3. Restart your mac.
  4. Launch Rectangle and enable settings for it as prompted.

View Debug Logging

  1. Hold down the alt (option) key with the Rectangle menu open.
  2. Select the "View Logging..." menu item, which is in place of the "About" menu item.
  3. Logging will appear in the window as you perform Rectangle commands.

Import & export JSON config

There are buttons for importing and exporting the config as a JSON file in the settings tab of the preferences window.

Upon launch, Rectangle will load a config file at ~/Library/Application Support/Rectangle/RectangleConfig.json if it is present and will rename that file with a time/date stamp so that it isn't read on subsequent launches.

Preferences Storage

The configuration for Rectangle is stored using NSUserDefaults, meaning it is stored in the following location: ~/Library/Preferences/com.knollsoft.Rectangle.plist Note that shortcuts in v0.41+ are stored in a different format and will not load in prior versions.

That file can be backed up or transferred to other machines.

If you are using Rectangle v0.44+, you can also use the import/export button in the Preferences pane to share to your preferences and keyboard shortcuts across machines using a JSON file.

[!NOTE]
If you are having issues with configuration options persisting after an application restart and you've installed using Homebrew, you will need to uninstall and reinstall with the --zap flag.

brew uninstall --zap rectangle
brew install rectangle

Uninstallation

Rectangle can be uninstalled by quitting the app and moving it to the trash. You can remove the Rectangle defaults from your machine with the following terminal command:

defaults delete com.knollsoft.Rectangle

[!TIP]
If you are uninstalling after installing with Homebrew, you should include the --zap flag to ensure it removes the plist entries too.

brew uninstall --zap rectangle

Contributing

Logic from Rectangle is used in the Multitouch app. The Rectangle Pro app is entirely built on top of Rectangle. If you contribute significant code or localizations that get merged into Rectangle, send me an email for a free license of Multitouch or Rectangle Pro. Contributors to Sparkle, MASShortcut, or Spectacle can also receive free Multitouch or Rectangle Pro licenses.

Localization

If you would like to contribute to localization, all of the translations are held in the Main.strings per language. If you would like to add a localization but one doesn't currently exist and you don't know how to create one, create an issue and a translation file can be initialized.

Pull requests for new localizations or improvements on existing localizations are welcome.

Running the app in Xcode (for developers)

Rectangle uses Swift Package Manager to install Sparkle and MASShortcut.

The original repository for MASShortcut was archived, so Rectangle uses my fork. If you want to make any changes that involve MASShortcut, please make a pull request on my fork.