nicoladefranceschi / Rectangle

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

Home Page:https://rectangleapp.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rectangle

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

image

System Requirements

Rectangle supports macOS v10.11+. If you're willing to test on earlier versions of macOS, this can be updated.

Installation

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

Or install with brew cask:

brew cask install 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 Area Resulting Action
Left or right edge Left or right half
Top Maximize
Corners Quarter in respective corner
Left or right edge, just above or below a corner Top or bottom half
Bottom left, center, or right third Respective third
Bottom left or right third, then drag to bottom center First 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"

Keyboard Shortcuts

The default keyboard shortcuts are based on Spectacle, but there is a recommended alternative set of defaults based on the Magnet app. This can be enabled by setting "alternateDefaultShortcuts" to true in NSUserDefaults for Rectangle with the following Terminal command:

defaults write com.knollsoft.Rectangle alternateDefaultShortcuts -bool true

Then restart the Rectangle app.

Differences with Spectacle

Spectacle used its own keyboard shortcut recorder, while Rectangle uses MASShortcut, a well maintained open source library for shortcut recording in macOS apps. This cuts down dramatically on the number of bugs that were only in Spectacle because of the custom shortcut recorder.

Additional features

  • 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.
  • There's an option to have windows traverse across displays on subsequent left or right executions, similar to what Microsoft provided in Windows 7.
  • Windows will snap when dragged to edges/corners of the screen. This can be disabled.

Details on halves to thirds (subsequent execution of half and quarter actions)

The default behavior for Rectangle is based on Spectacle. Each time you execute a half or quarter action, the width of the window will cycle through the following sizes: 1/2 -> 2/3 -> 1/3.

This behavior can be disabled with the following terminal command:

defaults write com.knollsoft.Rectangle subsequentExecutionMode -int 2

Followed by a restart of the app.

Note that the subsequentExecutionMode is also tied to the setting for traversing displays in the prefs.

Details on Almost Maximize

By default, "Almost Maximize" will resize the window to 90% of the screen (width & height). These values can be adjusted with the following terminal commands:

defaults write com.knollsoft.Rectangle almostMaximizeHeight -float <VALUE_BETWEEN_0_&_1>
defaults write com.knollsoft.Rectangle almostMaximizeWidth -float <VALUE_BETWEEN_0_&_1>

Followed by a restart of the app.

Details on Adding Gaps Between Windows

As of v0.17, gaps between windows can be added with the following command:

defaults write com.knollsoft.Rectangle gapSize -float <NUM_PIXELS>

Followed by a restart of the app.

Details on Move Up/Down/Left/Right

The current default behavior of these actions is to center the window along the edge that the window is being moved to.

As of v0.19, the centering can be disabled with the following command:

defaults write com.knollsoft.Rectangle centeredDirectionalMove -int 2

Followed by a restart of the app.

Contributing

Logic from Rectangle is used in the Multitouch app. If you contribute significant code or localizations that get merged into Rectangle, you get a free license of Multitouch. Contributors to Sparkle, MASShortcut, or Spectacle can also receive a free license of Multitouch (just send me a direct message on Gitter).

Localization

Initial localizations were done using DeepL and Google Translate, but many of them have been updated by contributors. Translations that weren't done by humans can definitely be improved. 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 CocoaPods to install Sparkle and MASShortcut.

  1. Make sure CocoaPods is installed and up to date on your machine (sudo gem install cocoapods).
  2. Execute pod install the root directory of the project.
  3. Open the generated xcworkspace file (open Rectangle.xcworkspace).

Signing

  • When running in Xcode (debug), Rectangle is signed to run locally with no developer ID configured.
  • You can run the app out of the box this way, but you might have to authorize the app in System Prefs every time you run it.
  • If you don't want to authorize in System Prefs every time you run it and you have a developer ID set up, you'll want to use that to sign it and additionally add the Hardened Runtime capability to the Rectangle and RectangleLauncher targets.

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, if possible.
  2. Restart your machine.
  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.

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.

Preferences Storage

The configuration for Rectangle is stored using NSUserDefaults, meaning it is stored in the following location: ~/Library/Preferences/com.knollsoft.Rectangle.plist

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

About

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

https://rectangleapp.com

License:Other


Languages

Language:Swift 99.6%Language:Ruby 0.4%