Skip to content

Latest commit

 

History

History
703 lines (479 loc) · 30.6 KB

File metadata and controls

703 lines (479 loc) · 30.6 KB

Rectangle Terminal Commands for Hidden Preferences

The preferences window is purposefully slim, but there's a lot that can be modified via Terminal. After executing a terminal command, restart the app as these values are loaded on application startup. For Rectangle Pro, please replace com.knollsoft.Rectangle with com.knollsoft.Hookshot for the following commands. A number of the commands below are for configuring keyboard shortcuts, and you'll need to know the key code and modifier flags integer values. You can use the free key codes app to help with this.

Contents

Keyboard Shortcuts

If you wish to change the default shortcuts after first launch click "Restore Default Shortcuts" in the settings tab of the preferences window. Alternatively, you can set it with the following terminal command followed by app restart. True is for the recommended shortcuts, false is for Spectacle's.

defaults write com.knollsoft.Rectangle alternateDefaultShortcuts -bool true

Adjust Behavior on Repeated Commands

This is now in the preferences window, but there's an option in the preferences for "Move to adjacent display on repeated left or right commands". If this setting is not checked, then 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.

The cycling behavior can be disabled entirely with:

defaults write com.knollsoft.Rectangle subsequentExecutionMode -int 2

subsequentExecutionMode accepts the following values: 0: halves to thirds Spectacle behavior (box unchecked) 1: cycle displays (box checked) for left/right actions 2: disabled 3: cycle displays for left/right actions, halves to thirds for the rest (old Rectangle behavior) 4: repeat same action on next display

Cycle thirds on repeated Center Half commands

Set Center Half to cycle thirds sizes: 1/2 -> 2/3 -> 1/3 with:

defaults write com.knollsoft.Rectangle centerHalfCycles -int 1

Resize on Directional Move

By default, the commands to move to certain edges will not resize the window. If resizeOnDirectionalMove is enabled, the halves to thirds mode is instead used. This means that when moving to the left/right, the width will be changed, and when moving to the top/bottom, the height will be changed. This size will cycle between 1/2 -> 2/3 -> 1/3 of the screen’s width/height.

Note that if subsequent execution mode is set to cycle displays when this is enabled, Move Left and Move Right will always resize to 1/2, and pressing it again will move to the next display.

defaults write com.knollsoft.Rectangle resizeOnDirectionalMove -bool true

Make the half actions tile like Windows or KDE

By default, Left Half, Right Half, Top Half and Bottom Half always give the window the full height or width of the screen. Enable this to have each of them only change its own axis and keep the other one, like the Win + arrow keys on Windows or keyboard tiling on KDE:

  • Left Half followed by Top Half puts the window in the top left quarter (so does Top Half followed by Left Half).
  • Inside a quarter, the action for the opposite edge expands the window along that axis: Bottom Half takes a top left quarter back to Left Half, Right Half takes it to Top Half.
  • Inside a quarter, the action for the edge the window is docked to cycles the window through the cycle sizes along that axis and keeps the other one: Left Half takes a top left quarter to two thirds wide, then one third wide, while Top Half does the same to its height. This follows the setting for repeated commands; when it does not resize, the window stays as it is.
  • The same goes for halves: Right Half followed by Left Half fills the screen.
  • Windows that are not tiled, and halves that get their own action again, behave as usual (repeated executions still cycle sizes or move across displays, depending on the setting for repeated commands).
defaults write com.knollsoft.Rectangle halvesPreserveOtherAxisSize -bool true

Adjust macOS Ventura Stage Manager size

By default, the Stage Manager area will be set to 190, if enabled.

defaults write com.knollsoft.Rectangle stageSize -float <VALUE>

To set it to a proportion of your screen's width, set it to a value between 0 and 1.

defaults write com.knollsoft.Rectangle stageSize -float <VALUE_BETWEEN_0_AND_1>

Enable Todo Mode

See the wiki for more info.

defaults write com.knollsoft.Rectangle todo -int 1

Only allow drag-to-snap when modifier keys are pressed

Modifier keys can be combined by adding the sum of Integer Values together.

Modifier Key Integer Value
cmd 1048576
option 524288
ctrl 262144
shift 131072
fn 8388608

This command would be for restricting snap to the cmd key:

defaults write com.knollsoft.Rectangle snapModifiers -int 1048576

Almost Maximize

By default, "Almost Maximize" will resize the window to 90% of the screen (width & height).

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

Repeated Maximize restores the previous size and position

By default, executing "Maximize" or "Almost Maximize" on a window that is already in that state does nothing. With this enabled, executing the same action again on a window that Rectangle has just maximized (or almost maximized) moves the window back to the size and position it had right before, so the shortcut toggles between the two. A window that was moved or resized by other means in between is maximized as usual.

This can also be toggled with the "Repeated Maximize restores the previous size and position" checkbox at the bottom of the "Extras" popover in the General tab of the Settings window.

defaults write com.knollsoft.Rectangle repeatedMaximizeRestoresPrevious -bool true

Add an extra centering command with custom size

This extra command is not available in the UI. You'll need to know which keycode and modifier flags you want.

defaults write com.knollsoft.Rectangle specified -dict-add keyCode -float 8 modifierFlags -float 1966080
defaults write com.knollsoft.Rectangle specifiedHeight -float 1050
defaults write com.knollsoft.Rectangle specifiedWidth -float 1680

Add an extra centering with prominence command

There is an extra command that horizontally centers the window but moves up the window vertically slightly from the center to add visual weight. Similar to extra centering you will need to know which keycode and modifier flags you want.

The key code is:

  • centerProminently

For example, the command for setting the shortcut to ctrl option command C would be:

defaults write com.knollsoft.Rectangle centerProminently -dict-add keyCode -float 8 modifierFlags -float 1835305

Add extra "ninths" sizing commands

Commands for resizing to screen ninths are not available in the UI.

The key codes are:

  • topLeftNinth
  • topCenterNinth
  • topRightNinth
  • middleLeftNinth
  • middleCenterNinth
  • middleRightNinth
  • bottomLeftNinth
  • bottomCenterNinth
  • bottomRightNinth

For example, the command for setting the top left ninth shortcut to ctrl opt shift 1 would be:

defaults write com.knollsoft.Rectangle topLeftNinth -dict-add keyCode -float 18 modifierFlags -float 917504

Add extra "eighths" sizing commands

Commands for resizing to screen eighths are not available in the UI. This divides the screen up into a 4x2 grid.

The key codes are:

  • topLeftEighth
  • topCenterLeftEighth
  • topCenterRightEighth
  • topRightEighth
  • bottomLeftEighth
  • bottomCenterLeftEighth
  • bottomCenterRightEighth
  • bottomRightEighth

For example, the command for setting the top left eighth shortcut to ctrl opt shift 1 would be:

defaults write com.knollsoft.Rectangle topLeftEighth -dict-add keyCode -float 18 modifierFlags -float 917504

Add additional "thirds" sizing commands

These commands for resizing to corner two-thirds are not available in the UI but can be configured via CLI.

The key codes are:

  • topLeftThird
  • topRightThird
  • bottomLeftThird
  • bottomRightThird

(these correspond to two-thirds, and when repeated will cycle through each of the calculations)

For example, the command for setting the top left two-thirds shortcut to ctrl opt shift 1 would be:

defaults write com.knollsoft.Rectangle topLeftThird -dict-add keyCode -float 18 modifierFlags -float 917504

Add doubling/halving window sizing commands

These commands for doubling/halving the window width/height are not available in the UI but can be configured via CLI.

The key codes are:

  • doubleHeightUp
  • doubleHeightDown
  • doubleWidthLeft
  • doubleWidthRight
  • halveHeightUp
  • halveHeightDown
  • halveWidthLeft
  • halveWidthRight

The action direction (e.g., "Right") is the direction that the center of the window will move towards as a result of resizing.

For example, the command for setting the doubleWidthRight shortcut to ctrl option shift right would be:

defaults write com.knollsoft.Rectangle doubleWidthRight -dict-add keyCode -float 124 modifierFlags -float 11403555

Add additional tiling and cascading commands

Commands for tiling and cascading the visible windows are not available in the UI but can be configured via CLI.

The key codes are:

  • tileAll
  • cascadeAll
  • cascadeActiveApp
  • tileActiveApp

tileAll and cascadeAll act on all visible windows.

cascadeActiveApp cascades and brings to the front only windows belonging to the currently active (foremost) app, leaving all other windows alone.

tileActiveApp tiles only windows belonging to the currently active (foremost) app into a grid, leaving all other windows alone.

For example, the command for setting the cascadeActiveApp shortcut to ctrl shift 2 would be:

defaults write com.knollsoft.Rectangle cascadeActiveApp -dict-add keyCode -float 2 modifierFlags -float 393475

Zone Layout (FancyZones)

Rectangle can divide the visible screen area into a grid of zones, and either tile all windows into those zones on demand, or snap a window into the zone under the cursor while you drag with ⇧ Shift held.

Enable or disable the feature (disabled by default):

defaults write com.knollsoft.Rectangle fancyZonesEnabled -bool true

Set the grid with fancyZonesRows and fancyZonesCols (each 1–4, default 2×3):

defaults write com.knollsoft.Rectangle fancyZonesRows -int 2
defaults write com.knollsoft.Rectangle fancyZonesCols -int 3

Each setting can be overridden per monitor by appending the monitor's localized name, e.g.:

defaults write com.knollsoft.Rectangle "fancyZonesRows_Built-in Retina Display" -int 3

Optionally restrict the Cycle Grid shortcut — and the status-menu grid options — to the checked grids. cycleSquareFancyZonesGrids is a bitmask: bit i set means the i-th candidate grid participates, where the candidates are 1×2, 1×3, 1×4, 2×2, 2×3, 2×4, 3×1, 3×2, 3×3, 3×4 (indices 0–9). The default 1023 enables every candidate:

defaults write com.knollsoft.Rectangle cycleSquareFancyZonesOnly -bool true
defaults write com.knollsoft.Rectangle cycleSquareFancyZonesGrids -int 1023
# e.g. only 2×2 (index 4) and 3×3 (index 9): 1<<4 | 1<<9 = 528
defaults write com.knollsoft.Rectangle cycleSquareFancyZonesGrids -int 528

Each display can have its own selection by appending the monitor's localized name, e.g.:

```bash
defaults write com.knollsoft.Rectangle "cycleSquareFancyZonesGrids_Built-in Retina Display" -int 528

Arrange (tile) all windows on the current screen into the zones. The default shortcut is ⌃⌥A — change it in Rectangle's preferences under "Show More", or bind a custom key like the tiling commands above:

defaults write com.knollsoft.Rectangle arrangeWindowsInZones -dict-add keyCode -float 2 modifierFlags -float 393475

Cycle the manual grid from the keyboard (no default shortcut — bind one like this):

defaults write com.knollsoft.Rectangle cycleFancyZonesGrid -dict-add keyCode -float 1 modifierFlags -float 393475

Shift-held grid picker

Hold ⇧ Shift (without dragging a window) and a translucent frosted-glass bar appears centered on the display under the cursor, listing every grid selectable for that display — the same candidates as the status menu, with the current grid marked ✓. Click an entry to switch, or press ←/→ to move the highlight: after a 0.4 s pause (or pressing return) the highlighted grid is applied and the windows are rearranged. The bar closes on Esc, on releasing Shift, or when a window drag starts.

The picker is part of the Zone Layout feature — it only appears while fancyZonesEnabled is true. No extra settings: it always offers the same candidate list as the status menu (respecting cycleSquareFancyZonesOnly/cycleSquareFancyZonesGrids when the cycle restriction is on).

Modify the "footprint" displayed for drag to snap area

Adjust the alpha (transparency). Default is 0.3.

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

Change the border width. Default is 2 (used to be 1).

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

Disable the fade.

defaults write com.knollsoft.Rectangle footprintFade -int 2

Change the color.

defaults write com.knollsoft.Rectangle footprintColor -string "{\"red\":0,\"blue\":0.5,\"green\":0.5}"

Change the animation duration. The value is a multiplier. Default is 0 (no animation).

defaults write com.knollsoft.Rectangle footprintAnimationDurationMultiplier -float <MULTIPLIER>

Move Up/Down/Left/Right: Don't center on edge

By default, the directional move will center the window along the edge that the window is being moved to.

defaults write com.knollsoft.Rectangle centeredDirectionalMove -int 2

Make Smaller limits

By default, "Make Smaller" will decrease the window until it reaches 25% of the screen (width & height).

Set either value to 0 to disable Rectangle's screen-relative limit for that dimension and rely on the application's native minimum size.

defaults write com.knollsoft.Rectangle minimumWindowWidth -float <VALUE_BETWEEN_0_&_1>
defaults write com.knollsoft.Rectangle minimumWindowHeight -float <VALUE_BETWEEN_0_&_1>

Make Smaller/Make Larger size increments

By default, "Make Smaller" and "Make Larger" change the window height/width by 30 pixels.

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

Make Smaller/Make Larger "curtain resize" with gaps

By default, windows touching the edge of the screen will keep those shared edges the same while only resizing the non-shared edge. With window gaps, this is a little ambiguous since the edges don't actually touch the screen, so you can disable it for traditional, floating resizing:

defaults write com.knollsoft.Rectangle curtainChangeSize -int 2

Make Smaller/Make Larger width only

By default, "Make Smaller" and "Make Larger" change both, the window height and the window width. If you only want to change the window width without changing window height, configure shortcuts for the largerWidth and smallerWidth commands.

For example, if you want to assign ctrl option ] to largerWidth and ctrl option [ to smallerWidth, the commands would be:

defaults write com.knollsoft.Rectangle largerWidth -dict-add keyCode -float 30 modifierFlags -float 786432
defaults write com.knollsoft.Rectangle smallerWidth -dict-add keyCode -float 33 modifierFlags -float 786432

Make Smaller/Make Larger height only

Similarly, if you only want to change the window height without changing window width, configure shortcuts for the largerHeight and smallerHeight commands.

For example, if you want to assign ctrl option shift ] to largerHeight and ctrl option shift [ to smallerHeight, the commands would be:

defaults write com.knollsoft.Rectangle largerHeight -dict-add keyCode -float 30 modifierFlags -float 917504
defaults write com.knollsoft.Rectangle smallerHeight -dict-add keyCode -float 33 modifierFlags -float 917504

Make Smaller shrink the height of full-height windows

By default, "Make Smaller" keeps the height of a window that spans the full height of the screen (for example after "Half" or "Maximize Height") and only shrinks its width. Enable this to shrink the height as well:

defaults write com.knollsoft.Rectangle smallerShrinksMaximizedHeight -bool true

Disabling window restore when moving windows

defaults write com.knollsoft.Rectangle unsnapRestore -int 2

Changing the margin for the snap areas

Each margin is configured separately, and has a default value of 5

defaults write com.knollsoft.Rectangle snapEdgeMarginTop -int 10
defaults write com.knollsoft.Rectangle snapEdgeMarginBottom -int 10
defaults write com.knollsoft.Rectangle snapEdgeMarginLeft -int 10
defaults write com.knollsoft.Rectangle snapEdgeMarginRight -int 10

Setting gaps at the screen edges

You can specify gaps at the edges of your screen that will be left uncovered by window resizing operations. This is useful if, for example, you use a dock replacement that should not have windows overlapping it.

defaults write com.knollsoft.Rectangle screenEdgeGapTop -int 10
defaults write com.knollsoft.Rectangle screenEdgeGapBottom -int 10
defaults write com.knollsoft.Rectangle screenEdgeGapLeft -int 10
defaults write com.knollsoft.Rectangle screenEdgeGapRight -int 10

You can also separately specify the gap for a screen with a notch. Useful for multi display setups if you are using a menubar replacement.

defaults write com.knollsoft.Rectangle screenEdgeGapTopNotch -int 5

If you want these gaps to be applied on your main screen only you can set screenEdgeGapsOnMainScreenOnly. Useful for multi display setups where only one screen has some dock replacement.

defaults write com.knollsoft.Rectangle screenEdgeGapsOnMainScreenOnly -bool true

Ignore specific drag to snap areas

Each drag to snap area on the edge of a screen can be ignored with a single Terminal command, but it's a bit field setting so you'll have to determine the bit field for which ones you want to disable.

Bit Snap Area Window Action
0 Top Maximize
1 Bottom Thirds
2 Left Left Half
3 Right Right Half
4 Top Left Top Left Corner
5 Top Right Top Right Corner
6 Bottom Left Bottom Left Corner
7 Bottom Right Bottom Right Corner
8 Top Left Below Corner Top Half
9 Top Right Below Corner Top Half
10 Bottom Left Above Corner Bottom Half
11 Bottom Right Above Corner Bottom Half

To disable the top (maximize) snap area, execute:

defaults write com.knollsoft.Rectangle ignoredSnapAreas -int 1

To disable the Top Half and Bottom Half snap areas, the bit field would be 1111 0000 0000, or 3840

defaults write com.knollsoft.Rectangle ignoredSnapAreas -int 3840

Disabling gaps when maximizing

By default, the "Gaps between windows" setting applies to "Maximize" and "Maximize Height".

To disable the gaps for "Maximize", execute:

defaults write com.knollsoft.Rectangle applyGapsToMaximize -int 2

To disable the gaps for "Maximize Height", execute:

defaults write com.knollsoft.Rectangle applyGapsToMaximizeHeight -int 2

Enabling snap areas for sixths

To enable snap areas for sixths corners, execute:

defaults write com.knollsoft.Rectangle sixthsSnapArea -bool true

Once enabled, you can drag a window to the corner, then move it along the edge towards the thirds area to snap to a sixth.

Move cursor with window

There's an option in the UI for moving the cursor with the window when going across displays, but here's an option for moving it with any shortcut:

defaults write com.knollsoft.Rectangle moveCursor -int 1

Control Enhanced UI handling

Some apps enable the macOS AXEnhancedUserInterface accessibility mode. Rectangle disables this mode while moving or resizing a window because its animated window updates can otherwise produce incorrect frames. Chromium browsers can also enable expensive web accessibility processing when the mode is restored.

Rectangle uses automatic handling by default: it restores Enhanced UI for other apps, but leaves it disabled after Rectangle window actions, when known Chromium browser families activate, and when one is already frontmost as Rectangle starts. VoiceOver and Switch Control keep the prior restore behavior. The behavior can be overridden with:

defaults write com.knollsoft.Rectangle enhancedUI -int <MODE>

enhancedUI accepts the following values:

Mode Behavior
1 Always restore Enhanced UI after a Rectangle window action if it was enabled beforehand. Use this when assistive software depends on the mode.
2 Disable Enhanced UI when encountered and do not restore it.
3 Behave like mode 2 and also disable Enhanced UI whenever the frontmost app changes.
4 Automatic handling (default).

Automatic handling can still interfere with third-party assistive software that enables Enhanced UI inside a Chromium browser; use mode 1 when that software depends on the mode. Modes 2 and 3 apply the same risk to every app. Legacy mode 0 is treated as mode 1.

Prevent a window that is quickly dragged above the menu bar from going into Mission Control

Important: This can cause issues with dragging and dropping in certain apps like Adobe Illustrator, and can affect text selection in a select few apps as well.

Windows that are slowly moved above the menu bar will still go into Mission Control.

Once this is enabled, the checkbox for it is visible in the Snap Areas tab of the Preferences window.

defaults write com.knollsoft.Rectangle missionControlDragging -int 2

Change the allowed off-screen distance. The value is in pixels and is tied to the speed. Default is 25.

defaults write com.knollsoft.Rectangle missionControlDraggingAllowedOffscreenDistance -float <DISTANCE>

Change the disallowed duration. The value is in milliseconds. Default is 250.

defaults write com.knollsoft.Rectangle missionControlDraggingDisallowedDuration -int <DURATION>

Change the behavior of double-click window title bar

To change the action (list):

defaults write com.knollsoft.Rectangle doubleClickTitleBar -int <ACTION_ID + 1>

To disable restore when double-clicked again:

defaults write com.knollsoft.Rectangle doubleClickTitleBarRestore -int 2

To disable double-click window title bar only for specific bundle ids (in example, Outlook):

defaults write com.knollsoft.Rectangle doubleClickTitleBarIgnoredApps -string "[\"com.microsoft.Outlook\"]"

Change the order of displays to order by x coordinate for next and prev displays commands

By default, display order is left-to-right, line-by-line. You can change this to be ordered by x coordinate, left-to-right, regardless of which vertical position of the display. This was the default behavior prior to v0.87.

defaults write com.knollsoft.Rectangle screensOrderedByX -int 1

Keep window size when moving a maximized window to another display

By default, moving a maximized window to the next or previous display re-maximizes it to fill the destination display. Disable this to keep the window's size and center it on the destination display instead (so a window maximized on a smaller display won't grow to fill a larger one). This can also be toggled from Settings via the "Maximize window when moved to another display" checkbox.

defaults write com.knollsoft.Rectangle autoMaximize -int 2

To restore the default behavior:

defaults write com.knollsoft.Rectangle autoMaximize -int 0

Attempt to preserve window position when moving to another display

By default, moving a window to the next, previous, or a specific display centers it on the destination display. Enable this to instead try preserving the window's position on the destination. If the previous action was a Rectangle snap (half, third, maximize, etc.), that snap is replayed on the destination display. If the window was positioned manually, its rect is mapped proportionally from the source display to the destination display (a window at the right third stays at the right third) and clamped so it never overflows. This is off by default.

defaults write com.knollsoft.Rectangle attemptMatchOnNextPrevDisplay -int 1

To disable it again:

defaults write com.knollsoft.Rectangle attemptMatchOnNextPrevDisplay -int 2

Offset cycling position when overlapping another window

When cycling through grid positions (sixths, eighths, ninths, twelfths, sixteenths, or quarters with quadrant cycling mode), the target position may land exactly on top of another window, hiding it completely. Enable this to apply a small offset when an overlap is detected, so you can see there's a window underneath.

defaults write com.knollsoft.Rectangle cyclingOverlapOffset -bool true

The default offset is 11pt. To customize the offset size:

defaults write com.knollsoft.Rectangle cyclingOverlapOffsetSize -float 16

By default, only one cascade layer is shown (the original window plus one offset). To allow more layers:

defaults write com.knollsoft.Rectangle cyclingOverlapMaxCascade -int 3

Show a badge with the stacked windows when hovering over a grid corner

When multiple windows are stacked at the same grid position, resting the cursor on that position's top-left corner shows a small badge with the stack count and a list of the window names. Clicking a name brings that window forward.

defaults write com.knollsoft.Rectangle stackBadge -bool true

Move windows that can't fill the snap area to the edge

Some windows can't be resized to fill a snap area — either because they're a fixed size, or because they're resizable but have a maximum size or a fixed aspect ratio (FaceTime is a common example). By default such a window aligns to the snap area's screen edge(s): a right-half snap anchors flush right, a corner snap anchors into the corner, and the window stays centered on any axis it can't fill. To choose a different behavior:

defaults write com.knollsoft.Rectangle moveFixedSizeToEdge -int 1  # align edges and corners (default)
defaults write com.knollsoft.Rectangle moveFixedSizeToEdge -int 2  # align corners only, center halves/sides
defaults write com.knollsoft.Rectangle moveFixedSizeToEdge -int 3  # center within the snap area