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:
For a grid of 3x3:
'0,0 1x1'
will be in the upper-left corner'2,0 1x1'
will be in the upper-right cornerAdditionally, 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.
Signature | hs.grid.HINTS |
---|---|
Type | Variable |
Description | A bidimensional array (table of tables of strings) holding the keyboard hints (as per Default Notes:
|
Signature | hs.grid.ui |
---|---|
Type | Variable |
Description | Allows customization of the modal resizing grid user interface This table contains variables that you can change to customize the look of the modal resizing grid. The default values are shown in the right hand side of the assignements below. To represent color values, you can use:
The following variables must be color values:
The following variables must be numbers (in screen points):
The following variables must be strings:
The following variables must be booleans:
|
Signature | hs.grid.adjustWindow(fn, window) -> hs.grid |
---|---|
Type | Function |
Description | Calls a user specified function to adjust a window's cell Parameters:
Returns:
|
Signature | hs.grid.get(win) -> cell |
---|---|
Type | Function |
Description | Gets the cell describing a window Parameters:
Returns:
|
Signature | hs.grid.getCell(cell, screen) -> hs.geometry |
---|---|
Type | Function |
Description | Gets the Parameters:
Returns:
|
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 |
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:
|
Signature | hs.grid.hide() |
---|---|
Type | Function |
Description | Hides the grid, if visible, and exits the modal resizing mode.
Call this function if you need to make sure the modal is exited without waiting for the user to press Parameters:
Returns:
Notes:
|
Signature | hs.grid.maximizeWindow(window) -> hs.grid |
---|---|
Type | Function |
Description | Moves and resizes a window to fill the entire grid Parameters:
Returns:
|
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:
|
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:
|
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:
|
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:
|
Signature | hs.grid.resizeWindowShorter(window) -> hs.grid |
---|---|
Type | Function |
Description | Resizes a window so its bottom edge moves one grid cell higher Parameters:
Returns:
|
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:
|
Signature | hs.grid.resizeWindowThinner(window) -> hs.grid |
---|---|
Type | Function |
Description | Resizes a window to be one cell thinner Parameters:
Returns:
|
Signature | hs.grid.resizeWindowWider(window) -> hs.grid |
---|---|
Type | Function |
Description | Resizes a window to be one cell wider Parameters:
Returns:
Notes:
|
Signature | hs.grid.set(win, cell, screen) -> hs.grid |
---|---|
Type | Function |
Description | Sets the cell for a window on a particular screen Parameters:
Returns:
|
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:
Usage: hs.grid.setGrid('5x3','Color LCD') -- sets the grid to 5x3 for any screen named "Color LCD" hs.grid.setGrid('8x5','1920x1080') -- sets the grid to 8x5 for all screens with a 1920x1080 resolution hs.grid.setGrid'4x4' -- sets the default grid to 4x4 |
Signature | hs.grid.setMargins(margins) -> hs.grid |
---|---|
Type | Function |
Description | Sets the margins between windows Parameters:
Returns:
|
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.
In most cases this function should be invoked via Parameters:
Returns:
Notes:
|
Signature | hs.grid.snap(win) -> hs.grid |
---|---|
Type | Function |
Description | Snaps a window into alignment with the nearest grid lines Parameters:
Returns:
|
Signature | hs.grid.toggleShow([exitedCallback][, multipleWindows]) |
---|---|
Type | Function |
Description | Toggles the grid and modal resizing mode - see Parameters: see Returns:
|