On this page
hs.grid
Move/resize windows within a grid
The grid partitions your screens for the purposes of window management. The default layout of the grid is 3 columns by 3 rows. You can specify different grid layouts for different screens and/or screen resolutions.
Windows that are aligned with the grid have their location and size described as a cell
. Each cell is an hs.geometry
rect with these fields:
- x - The column of the left edge of the window
- y - The row of the top edge of the window
- w - The number of columns the window occupies
- h - The number of rows the window occupies
For a grid of 3x3:
- a cell
'0,0 1x1'
will be in the upper-left corner - a cell
'2,0 1x1'
will be in the upper-right corner - and so on...
Additionally, a modal keyboard driven interface for interactive resizing is provided via hs.grid.show()
; The grid will be overlaid on the focused or frontmost window's screen with keyboard hints. To resize/move the window, you can select the corner cells of the desired position. For a move-only, you can select a cell and confirm with 'return'. The selected cell will become the new upper-left of the window. You can also use the arrow keys to move the window onto adjacent screens, and the tab/shift-tab keys to cycle to the next/previous window. Once you selected a cell, you can use the arrow keys to navigate through the grid. In this case, the grid will highlight the selected cells. After highlighting enough cells, press enter to move/resize the window to the highlighted area.
API Overview
- Variables - Configurable values
- Functions - API calls offered directly by the extension
API Documentation
Variables
HINTS
Signature | hs.grid.HINTS |
---|---|
Type | Variable |
Description | A bidimensional array (table of tables of strings) holding the keyboard hints (as per |
Notes |
|
Source | extensions/grid/grid.lua line 601 |
ui
Signature | hs.grid.ui |
---|---|
Type | Variable |
Description | Allows customization of the modal resizing grid user interface |
Source | extensions/grid/grid.lua line 650 |
Functions
adjustWindow
Signature | hs.grid.adjustWindow(fn, window) -> hs.grid |
---|---|
Type | Function |
Description | Calls a user specified function to adjust a window's cell |
Parameters |
|
Returns |
|
Source | extensions/grid/grid.lua line 372 |
get
Signature | hs.grid.get(win) -> cell |
---|---|
Type | Function |
Description | Gets the cell describing a window |
Parameters |
|
Returns |
|
Source | extensions/grid/grid.lua line 243 |
getCell
Signature | hs.grid.getCell(cell, screen) -> hs.geometry |
---|---|
Type | Function |
Description | Gets the |
Parameters |
|
Returns |
|
Source | extensions/grid/grid.lua line 266 |
getGrid
Signature | hs.grid.getGrid(screen) -> hs.geometry size |
---|---|
Type | Function |
Description | Gets the defined grid size for a given screen or screen resolution |
Parameters |
|
Returns |
|
Notes |
Usage: local mygrid = hs.grid.getGrid('1920x1080') -- gets the defined grid for all screens with a 1920x1080 resolution local defgrid=hs.grid.getGrid() defgrid.w=defgrid.w+2 -- increases the number of columns in the default grid by 2 |
Source | extensions/grid/grid.lua line 117 |
getGridFrame
Signature | hs.grid.getGridFrame(screen) -> hs.geometry rect |
---|---|
Type | Function |
Description | Gets the defined grid frame for a given screen or screen resolution. |
Parameters |
|
Returns |
|
Source | extensions/grid/grid.lua line 154 |
hide
Signature | hs.grid.hide() |
---|---|
Type | Function |
Description | Hides the grid, if visible, and exits the modal resizing mode. |
Parameters |
|
Returns |
|
Notes |
|
Source | extensions/grid/grid.lua line 207 |
maximizeWindow
Signature | hs.grid.maximizeWindow(window) -> hs.grid |
---|---|
Type | Function |
Description | Moves and resizes a window to fill the entire grid |
Parameters |
|
Returns |
|
Source | extensions/grid/grid.lua line 400 |
pushWindowDown
Signature | hs.grid.pushWindowDown(window) -> hs.grid |
---|---|
Type | Function |
Description | Moves a window one grid cell down the screen, or onto the adjacent screen's grid when necessary |
Parameters |
|
Returns |
|
Source | extensions/grid/grid.lua line 515 |
pushWindowLeft
Signature | hs.grid.pushWindowLeft(window) -> hs.grid |
---|---|
Type | Function |
Description | Moves a window one grid cell to the left, or onto the adjacent screen's grid when necessary |
Parameters |
|
Returns |
|
Source | extensions/grid/grid.lua line 430 |
pushWindowRight
Signature | hs.grid.pushWindowRight(window) -> hs.grid |
---|---|
Type | Function |
Description | Moves a window one cell to the right, or onto the adjacent screen's grid when necessary |
Parameters |
|
Returns |
|
Source | extensions/grid/grid.lua line 454 |
pushWindowUp
Signature | hs.grid.pushWindowUp(window) -> hs.grid |
---|---|
Type | Function |
Description | Moves a window one grid cell up the screen, or onto the adjacent screen's grid when necessary |
Parameters |
|
Returns |
|
Source | extensions/grid/grid.lua line 540 |
resizeWindowShorter
Signature | hs.grid.resizeWindowShorter(window) -> hs.grid |
---|---|
Type | Function |
Description | Resizes a window so its bottom edge moves one grid cell higher |
Parameters |
|
Returns |
|
Source | extensions/grid/grid.lua line 564 |
resizeWindowTaller
Signature | hs.grid.resizeWindowTaller(window) -> hs.grid |
---|---|
Type | Function |
Description | Resizes a window so its bottom edge moves one grid cell lower |
Parameters |
|
Returns |
|
Notes |
|
Source | extensions/grid/grid.lua line 577 |
resizeWindowThinner
Signature | hs.grid.resizeWindowThinner(window) -> hs.grid |
---|---|
Type | Function |
Description | Resizes a window to be one cell thinner |
Parameters |
|
Returns |
|
Source | extensions/grid/grid.lua line 502 |
resizeWindowWider
Signature | hs.grid.resizeWindowWider(window) -> hs.grid |
---|---|
Type | Function |
Description | Resizes a window to be one cell wider |
Parameters |
|
Returns |
|
Notes |
|
Source | extensions/grid/grid.lua line 479 |
set
Signature | hs.grid.set(win, cell, screen) -> hs.grid |
---|---|
Type | Function |
Description | Sets the cell for a window on a particular screen |
Parameters |
|
Returns |
|
Source | extensions/grid/grid.lua line 295 |
setGrid
Signature | hs.grid.setGrid(grid,screen,frame) -> hs.grid |
---|---|
Type | Function |
Description | Sets the grid size for a given screen or screen resolution |
Parameters |
|
Returns |
|
Examples | |
Source | extensions/grid/grid.lua line 48 |
setMargins
Signature | hs.grid.setMargins(margins) -> hs.grid |
---|---|
Type | Function |
Description | Sets the margins between windows |
Parameters |
|
Returns |
|
Source | extensions/grid/grid.lua line 98 |
show
Signature | hs.grid.show([exitedCallback][, multipleWindows]) |
---|---|
Type | Function |
Description | Shows the grid and starts the modal interactive resizing process for the focused or frontmost window. |
Parameters |
|
Returns |
|
Notes |
|
Source | extensions/grid/grid.lua line 187 |
snap
Signature | hs.grid.snap(win) -> hs.grid |
---|---|
Type | Function |
Description | Snaps a window into alignment with the nearest grid lines |
Parameters |
|
Returns |
|
Source | extensions/grid/grid.lua line 353 |
toggleShow
Signature | hs.grid.toggleShow([exitedCallback][, multipleWindows]) |
---|---|
Type | Function |
Description | Toggles the grid and modal resizing mode - see |
Parameters |
|
Returns |
|
Source | extensions/grid/grid.lua line 221 |
© 2014–2017 Hammerspoon contributors
Licensed under the MIT License.
https://www.hammerspoon.org/docs/hs.grid.html